Skip to content

Commit 39a5930

Browse files
authored
Merge pull request #477 from AlgorithmWithGod/suyeun84
[20250716] BOJ / G5 / 강의실 배정 / 김수연
2 parents d3e33aa + 95bfd26 commit 39a5930

File tree

1 file changed

+43
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)