We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4043f06 commit 16d18cfCopy full SHA for 16d18cf
최어진/10주차/260303.js
@@ -0,0 +1,30 @@
1
+/* 백준 1863번: 스카이라인 쉬운거 (2회차) */
2
+
3
+const fs = require('fs');
4
+const lines = fs.readFileSync('/dev/stdin').toString().split('\n');
5
+let ptr = 0;
6
+const input = () => lines[ptr++];
7
8
+// N <= 5 * 10^4
9
+const N = Number(input());
10
+const stack = [];
11
+let answer = 0;
12
13
+Array.from({ length: N }, () => {
14
+ const [x, y] = input()
15
+ .split(' ')
16
+ .map((n) => +n);
17
+ // console.log(x, y);
18
19
+ while (stack.length > 0 && stack[stack.length - 1] > y) {
20
+ answer++;
21
+ stack.pop();
22
+ }
23
24
+ if (stack.length > 0 && stack[stack.length - 1] === y) return;
25
+ if (y === 0) return;
26
+ stack.push(y);
27
+ // console.log(answer, stack, '\n');
28
+});
29
30
+console.log(answer + stack.length);
0 commit comments