File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-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+
7+ static class study {
8+ int s, e;
9+ study (int s , int e ) {
10+ this . s = s;
11+ this . e = e;
12+ }
13+ }
14+
15+ public static void main (String [] args ) throws Exception {
16+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
17+ StringTokenizer st;
18+ int N = Integer . parseInt(br. readLine());
19+
20+ study[] arr = new study [N ];
21+
22+ for (int i = 0 ; i < N ; i++ ) {
23+ st = new StringTokenizer (br. readLine());
24+ st. nextToken();
25+ int s = Integer . parseInt(st. nextToken());
26+ int e = Integer . parseInt(st. nextToken());
27+ arr[i] = new study(s, e);
28+ }
29+
30+ Arrays . sort(arr, (a, b) - > a. s - b. s);
31+
32+ PriorityQueue<Integer > pq = new PriorityQueue<> ();
33+
34+ for (study s : arr) {
35+ if (! pq. isEmpty() && pq. peek() <= s. s) {
36+ pq. poll();
37+ }
38+
39+ pq. offer(s. e);
40+ }
41+
42+ System . out. println(pq. size());
43+ }
44+ }
45+ ```
You can’t perform that action at this time.
0 commit comments