Skip to content

Commit 83653b9

Browse files
authored
[20251127] BOJ / G5 / 강의실 / 설진영
1 parent 34a6a43 commit 83653b9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
int n = Integer.parseInt(br.readLine());
9+
10+
int[][] lectures = new int[n][2];
11+
for (int i = 0; i < n; i++) {
12+
StringTokenizer st = new StringTokenizer(br.readLine());
13+
st.nextToken();
14+
lectures[i][0] = Integer.parseInt(st.nextToken());
15+
lectures[i][1] = Integer.parseInt(st.nextToken());
16+
}
17+
18+
Arrays.sort(lectures, (a, b) -> a[0] - b[0]);
19+
20+
PriorityQueue<Integer> pq = new PriorityQueue<>();
21+
22+
for (int[] lecture : lectures) {
23+
if (!pq.isEmpty() && pq.peek() <= lecture[0]) {
24+
pq.poll();
25+
}
26+
pq.offer(lecture[1]);
27+
}
28+
29+
System.out.println(pq.size());
30+
}
31+
}
32+
```

0 commit comments

Comments
 (0)