File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class Main {
6+ public static void main (String [] args ) throws IOException {
7+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
8+ int n = Integer . parseInt(br. readLine());
9+
10+ int [][] lectures = new int [n][2 ];
11+ for (int i = 0 ; i < n; i++ ) {
12+ StringTokenizer st = new StringTokenizer (br. readLine());
13+ st. nextToken();
14+ lectures[i][0 ] = Integer . parseInt(st. nextToken());
15+ lectures[i][1 ] = Integer . parseInt(st. nextToken());
16+ }
17+
18+ Arrays . sort(lectures, (a, b) - > a[0 ] - b[0 ]);
19+
20+ PriorityQueue<Integer > pq = new PriorityQueue<> ();
21+
22+ for (int [] lecture : lectures) {
23+ if (! pq. isEmpty() && pq. peek() <= lecture[0 ]) {
24+ pq. poll();
25+ }
26+ pq. offer(lecture[1 ]);
27+ }
28+
29+ System . out. println(pq. size());
30+ }
31+ }
32+ ```
You can’t perform that action at this time.
0 commit comments