Skip to content

Commit 7b4dcdb

Browse files
authored
[20251127] BOJ / G5 / 강의실 / 이준희
1 parent ae926ba commit 7b4dcdb

File tree

1 file changed

+45
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)