Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions 0224LJH/202508/30 BOJ 스카이라인 쉬운거.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
```java
import java.io.*;
import java.util.*;

public class Main {

static int cnt,ans;
static int[] arr;

public static void main(String[] args) throws Exception {
init();
process();
print();

}

public static void init() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
cnt = Integer.parseInt(br.readLine());
arr = new int[cnt];
for (int i = 0; i < cnt; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
st.nextToken();
arr[i] = Integer.parseInt(st.nextToken());
}
ans = 0;
}

public static void process(){
PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
for (int i = 0; i < cnt; i++) {
int height = arr[i];

while (!pq.isEmpty() && pq.peek() > height) {
pq.poll();
ans++;
}

if (height == 0) continue;

if (pq.isEmpty() || pq.peek() != height) pq.add(height);


}

ans += pq.size();
}

public static void print(){
System.out.println(ans);
}


}
```