File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .*;
3
+
4
+ class Main {
5
+
6
+ static int n , m , L ;
7
+ static int [] places ;
8
+
9
+ public static void main (String [] args ) throws Exception {
10
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
11
+ BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System .out ));
12
+ StringTokenizer st = new StringTokenizer (br .readLine ());
13
+ n = Integer .parseInt (st .nextToken ());
14
+ m = Integer .parseInt (st .nextToken ());
15
+ L = Integer .parseInt (st .nextToken ());
16
+
17
+ places = new int [m + 1 ];
18
+ for (int i = 1 ; i <= m ; i ++) {
19
+ places [i ] = Integer .parseInt (br .readLine ());
20
+ }
21
+ StringBuilder answer = new StringBuilder ();
22
+ for (int i = 0 ; i < n ; i ++) {
23
+ int target = Integer .parseInt (br .readLine ());
24
+
25
+ int l = 0 ;
26
+ int r = 4_000_000 ;
27
+
28
+ while (l < r ) {
29
+ int mid = (l + r ) / 2 ;
30
+
31
+ int count = 0 ;
32
+ int preCut = 0 ;
33
+ for (int j = 1 ; j <= m ; j ++) {
34
+ if (places [j ] - preCut >= mid ) {
35
+ count ++;
36
+ preCut = places [j ];
37
+ }
38
+ }
39
+ if (L - preCut < mid ) {
40
+ count --;
41
+ }
42
+
43
+ if (count < target ) {
44
+ r = mid ;
45
+ } else {
46
+ l = mid + 1 ;
47
+ }
48
+ }
49
+ answer .append (l - 1 ).append ("\n " );
50
+ }
51
+
52
+ bw .write (answer .toString ());
53
+ bw .flush ();
54
+ bw .close ();
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments