Skip to content

Commit af696a3

Browse files
authored
[20250418] BOJ / G5 / 회의실 배정 / 이강현
1 parent 513368a commit af696a3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> {
14+
if (a[1] == b[1]) {
15+
return a[0] - b[0];
16+
} else {
17+
return a[1] - b[1];
18+
}
19+
});
20+
for (int i = 0; i < N; i++) {
21+
st = new StringTokenizer(br.readLine());
22+
pq.add(new int[] {Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())});
23+
}
24+
int cnt = 0;
25+
int curTime = 0;
26+
while (!pq.isEmpty()) {
27+
int[] cur = pq.poll();
28+
if (cur[0] >= curTime) {
29+
cnt++;
30+
curTime = cur[1];
31+
}
32+
}
33+
bw.write(cnt + "");
34+
bw.close();
35+
}
36+
}
37+
38+
39+
40+
```

0 commit comments

Comments
 (0)