File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments