File tree Expand file tree Collapse file tree 1 file changed +81
-0
lines changed
Expand file tree Collapse file tree 1 file changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+
3+ import java.util.* ;
4+ import java.io.* ;
5+
6+ class Main {
7+
8+ // IO field
9+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
10+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
11+ static StringTokenizer st;
12+
13+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
14+ static int nextInt() {return Integer . parseInt(st. nextToken());}
15+ static long nextLong() {return Long . parseLong(st. nextToken());}
16+ static void bwEnd() throws Exception {bw. flush();bw. close();}
17+
18+ // Additional field
19+ static int N , M , C , K ;
20+ static List<int[]> wrong;
21+ static boolean [] exist;
22+ static int max_x = 0 ;
23+
24+ public static void main(String [] args) throws Exception {
25+
26+ ready();
27+ solve();
28+
29+ bwEnd();
30+
31+ }
32+
33+ static void ready() throws Exception {
34+
35+ nextLine();
36+ N = nextInt();
37+ M = nextInt();
38+
39+ C = Integer . parseInt(br. readLine());
40+ K = Integer . parseInt(br. readLine());
41+ wrong = new ArrayList<> ();
42+ exist = new boolean [M + 1 ];
43+
44+ for (int i= 0 ;i< K ;i++ ){
45+ nextLine();
46+ int x = nextInt(), y = nextInt();
47+ wrong. add(new int []{x,y});
48+ max_x = Math . max(max_x, x);
49+ exist[y] = true ;
50+ }
51+
52+ }
53+
54+ static void solve() throws Exception {
55+
56+ int s = max_x, e = M , m = (s+ e) >> 1 ;
57+ while (s < e){
58+
59+ // m 센티미터의 색종이들 C개로 다 가릴 수 있는지?
60+ int cnt = 0 ;
61+ int p = 1 ;
62+ while (p <= M ){
63+ while (p <= M && ! exist[p]) p++ ;
64+ if (p > M ) break ;
65+ cnt++ ;
66+ p += m;
67+ }
68+
69+ if (cnt > C ) s = m+ 1 ;
70+ else e = m;
71+ m = (s+ e)>> 1 ;
72+
73+ }
74+
75+ bw. write(m+ " \n " );
76+
77+ }
78+
79+ }
80+
81+ ```
You can’t perform that action at this time.
0 commit comments