File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-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 Main {
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 M = nextInt();
15+ int L = nextInt();
16+ if (N > 0 ) nextLine();
17+ int [] pos = new int [N + 2 ];
18+ pos[0 ] = 0 ;
19+ for (int i = 1 ; i <= N ; i++ ) pos[i] = nextInt();
20+ pos[N + 1 ] = L ;
21+ Arrays . sort(pos);
22+
23+ int start = 1 , end = L - 1 ;
24+ while (start <= end) {
25+ int mid = (start + end) / 2 ;
26+ int cnt = 0 ;
27+ for (int i = 1 ; i < N + 2 ; i++ ) cnt += ((pos[i] - pos[i- 1 ] - 1 ) / mid);
28+
29+ if (cnt > M ) start = mid + 1 ;
30+ else end = mid - 1 ;
31+ }
32+ System . out. println(start);
33+ }
34+ }
35+ ```
You can’t perform that action at this time.
0 commit comments