Skip to content

Commit 8109186

Browse files
authored
[20250729] BOJ / G5 / 강의실 배정 / 이강현
1 parent 0c8937b commit 8109186

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
```java
2+
import java.util.*;
3+
import java.io.*;
4+
5+
public class Main {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
static StringTokenizer st;
9+
static int N;
10+
11+
public static void main(String[] args) throws Exception {
12+
N = Integer.parseInt(br.readLine());
13+
List<int[]> arr = new LinkedList<>();
14+
15+
for (int i = 0; i < N; i++) {
16+
st = new StringTokenizer(br.readLine());
17+
arr.add(new int[]{Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())});
18+
}
19+
Collections.sort(arr,(a,b) -> a[0] - b[0]);
20+
21+
PriorityQueue<Integer> pq = new PriorityQueue<>();
22+
23+
int ans = 1;
24+
for (int[] cur : arr) {
25+
while(!pq.isEmpty() && pq.peek() <= cur[0]){
26+
pq.poll();
27+
}
28+
pq.offer(cur[1]);
29+
ans = Math.max(ans,pq.size());
30+
}
31+
bw.write(ans+"");
32+
bw.close();
33+
}
34+
}
35+
```

0 commit comments

Comments
 (0)