File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-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 boj2457 {
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+ Flower [] flowers = new Flower [N ];
15+ for (int i = 0 ; i < N ; i++ ) {
16+ nextLine();
17+ flowers[i] = new Flower (nextInt()* 100 + nextInt(), nextInt()* 100 + nextInt());
18+ }
19+ Arrays . sort(flowers, (o1, o2)- > {
20+ if (o1. start == o2. start) return o2. end - o1. end;
21+ return o1. start - o2. start;
22+ });
23+ int start = 301 ;
24+ int end = 1201 ;
25+ int maxEnd = 0 ;
26+ int answer = 0 ;
27+ int idx = 0 ;
28+ while (start < end) {
29+ boolean flag = false ;
30+ for (int i = idx; i < N ; i++ ) {
31+ if (flowers[i]. start > start) break ;
32+ if (flowers[i]. end > maxEnd) {
33+ maxEnd = flowers[i]. end;
34+ idx = i+ 1 ;
35+ flag = true ;
36+ }
37+ }
38+ if (flag) {
39+ answer++ ;
40+ start = maxEnd;
41+ } else break ;
42+ }
43+ System . out. println(maxEnd < end ? " 0" : answer);
44+ }
45+
46+ static class Flower {
47+ int start, end;
48+ public Flower (int start , int end ) {
49+ this . start = start;
50+ this . end = end;
51+ }
52+ }
53+ }
54+ ```
You can’t perform that action at this time.
0 commit comments