#include<iostream>
#include<algorithm>
using namespace std;
typedef long long Int;
Int n, t, k;
Int x[108000];
Int X[108000];
bool dp[2][108000];
Int cnt;
bool check(Int v){
for(Int i = 0;i < n;i++)X[i] = x[i] - 2 * v * t * i;
Int gl = k, gr = k;
for(Int i = k;i >= 0;i--){
if(X[gl] <= X[i])gl = i;
}
for(Int i = k;i < n;i++){
if(X[gr] >= X[i])gr = i;
}
Int l = k, r = k;
while(true){
bool change = false;
Int nl = l;
while(true){
if(nl - 1 >= gl && X[nl - 1] >= X[r])nl--;
else break;
if(X[nl] >= X[l] || nl == gl)break;
}
if(X[nl] >= X[l] && l != nl){
l = nl;
change = true;
}
Int nr = r;
while(true){
if(nr + 1 <= gr && X[nr + 1] <= X[l])nr++;
else break;
if(X[nr] <= X[r] || nr == gr)break;
}
if(X[nr] <= X[r] && r != nr){
r = nr;
change = true;
}
if(!change)break;
}
if(l != gl || r != gr)return false;
l = 0;
r = n-1;
if(X[l] < X[r])return false;
while(true){
bool change = false;
Int nl = l;
while(true){
if(nl + 1 <= gl && X[nl + 1] >= X[r])nl++;
else break;
if(X[nl] >= X[l] || nl == gl)break;
}
if(X[nl] >= X[l] && nl != l){
l = nl;
change = true;
}
Int nr = r;
while(true){
if(nr - 1 >= gr && X[nr - 1] <= X[l])nr--;
else break;
if(X[nr] <= X[r] || nr == gr)break;
}
if(X[nr] <= X[r] && nr != r){
r = nr;
change = true;
}
if(!change)break;
}
return (r == gr && l == gl);
}
int main(){
cin >> n >> k >> t;
k--;
for(Int i = 0;i < n;i++){
cin >> x[i];
}
bool same_check = true;
for(int i = 0;i < n;i++){
if(x[i] != x[0])same_check = false;
}
if(same_check){
cout << 0 << endl;
return 0;
}
Int bottom = 0, top = x[n-1];
while(top - bottom > 1){
Int mid = (top + bottom) / 2;
if(check(mid))top = mid;
else bottom = mid;
}
cout << top << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3916 KB |
Output is correct |
2 |
Correct |
0 ms |
3916 KB |
Output is correct |
3 |
Correct |
0 ms |
3916 KB |
Output is correct |
4 |
Correct |
0 ms |
3916 KB |
Output is correct |
5 |
Correct |
0 ms |
3916 KB |
Output is correct |
6 |
Correct |
0 ms |
3916 KB |
Output is correct |
7 |
Correct |
0 ms |
3916 KB |
Output is correct |
8 |
Correct |
0 ms |
3916 KB |
Output is correct |
9 |
Correct |
0 ms |
3916 KB |
Output is correct |
10 |
Correct |
0 ms |
3916 KB |
Output is correct |
11 |
Correct |
0 ms |
3916 KB |
Output is correct |
12 |
Correct |
0 ms |
3916 KB |
Output is correct |
13 |
Correct |
0 ms |
3916 KB |
Output is correct |
14 |
Correct |
0 ms |
3916 KB |
Output is correct |
15 |
Correct |
0 ms |
3916 KB |
Output is correct |
16 |
Correct |
0 ms |
3916 KB |
Output is correct |
17 |
Correct |
0 ms |
3916 KB |
Output is correct |
18 |
Correct |
0 ms |
3916 KB |
Output is correct |
19 |
Correct |
0 ms |
3916 KB |
Output is correct |
20 |
Correct |
0 ms |
3916 KB |
Output is correct |
21 |
Correct |
0 ms |
3916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3916 KB |
Output is correct |
2 |
Correct |
0 ms |
3916 KB |
Output is correct |
3 |
Correct |
0 ms |
3916 KB |
Output is correct |
4 |
Correct |
0 ms |
3916 KB |
Output is correct |
5 |
Correct |
0 ms |
3916 KB |
Output is correct |
6 |
Correct |
0 ms |
3916 KB |
Output is correct |
7 |
Correct |
0 ms |
3916 KB |
Output is correct |
8 |
Correct |
0 ms |
3916 KB |
Output is correct |
9 |
Correct |
0 ms |
3916 KB |
Output is correct |
10 |
Correct |
0 ms |
3916 KB |
Output is correct |
11 |
Correct |
0 ms |
3916 KB |
Output is correct |
12 |
Correct |
0 ms |
3916 KB |
Output is correct |
13 |
Correct |
0 ms |
3916 KB |
Output is correct |
14 |
Correct |
0 ms |
3916 KB |
Output is correct |
15 |
Correct |
0 ms |
3916 KB |
Output is correct |
16 |
Correct |
0 ms |
3916 KB |
Output is correct |
17 |
Correct |
0 ms |
3916 KB |
Output is correct |
18 |
Correct |
0 ms |
3916 KB |
Output is correct |
19 |
Correct |
0 ms |
3916 KB |
Output is correct |
20 |
Correct |
0 ms |
3916 KB |
Output is correct |
21 |
Correct |
0 ms |
3916 KB |
Output is correct |
22 |
Correct |
0 ms |
3916 KB |
Output is correct |
23 |
Correct |
0 ms |
3916 KB |
Output is correct |
24 |
Correct |
0 ms |
3916 KB |
Output is correct |
25 |
Correct |
0 ms |
3916 KB |
Output is correct |
26 |
Correct |
0 ms |
3916 KB |
Output is correct |
27 |
Correct |
0 ms |
3916 KB |
Output is correct |
28 |
Correct |
0 ms |
3916 KB |
Output is correct |
29 |
Correct |
0 ms |
3916 KB |
Output is correct |
30 |
Correct |
0 ms |
3916 KB |
Output is correct |
31 |
Correct |
0 ms |
3916 KB |
Output is correct |
32 |
Correct |
0 ms |
3916 KB |
Output is correct |
33 |
Correct |
0 ms |
3916 KB |
Output is correct |
34 |
Correct |
0 ms |
3916 KB |
Output is correct |
35 |
Correct |
0 ms |
3916 KB |
Output is correct |
36 |
Correct |
0 ms |
3916 KB |
Output is correct |
37 |
Correct |
0 ms |
3916 KB |
Output is correct |
38 |
Correct |
0 ms |
3916 KB |
Output is correct |
39 |
Correct |
0 ms |
3916 KB |
Output is correct |
40 |
Correct |
0 ms |
3916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3916 KB |
Output is correct |
2 |
Correct |
0 ms |
3916 KB |
Output is correct |
3 |
Correct |
0 ms |
3916 KB |
Output is correct |
4 |
Correct |
0 ms |
3916 KB |
Output is correct |
5 |
Correct |
0 ms |
3916 KB |
Output is correct |
6 |
Correct |
0 ms |
3916 KB |
Output is correct |
7 |
Correct |
0 ms |
3916 KB |
Output is correct |
8 |
Correct |
0 ms |
3916 KB |
Output is correct |
9 |
Correct |
0 ms |
3916 KB |
Output is correct |
10 |
Correct |
0 ms |
3916 KB |
Output is correct |
11 |
Correct |
0 ms |
3916 KB |
Output is correct |
12 |
Correct |
0 ms |
3916 KB |
Output is correct |
13 |
Correct |
0 ms |
3916 KB |
Output is correct |
14 |
Correct |
0 ms |
3916 KB |
Output is correct |
15 |
Correct |
0 ms |
3916 KB |
Output is correct |
16 |
Correct |
0 ms |
3916 KB |
Output is correct |
17 |
Correct |
0 ms |
3916 KB |
Output is correct |
18 |
Correct |
0 ms |
3916 KB |
Output is correct |
19 |
Correct |
0 ms |
3916 KB |
Output is correct |
20 |
Correct |
0 ms |
3916 KB |
Output is correct |
21 |
Correct |
0 ms |
3916 KB |
Output is correct |
22 |
Correct |
0 ms |
3916 KB |
Output is correct |
23 |
Correct |
0 ms |
3916 KB |
Output is correct |
24 |
Correct |
0 ms |
3916 KB |
Output is correct |
25 |
Correct |
0 ms |
3916 KB |
Output is correct |
26 |
Correct |
0 ms |
3916 KB |
Output is correct |
27 |
Correct |
0 ms |
3916 KB |
Output is correct |
28 |
Correct |
0 ms |
3916 KB |
Output is correct |
29 |
Correct |
0 ms |
3916 KB |
Output is correct |
30 |
Correct |
0 ms |
3916 KB |
Output is correct |
31 |
Correct |
0 ms |
3916 KB |
Output is correct |
32 |
Correct |
0 ms |
3916 KB |
Output is correct |
33 |
Correct |
0 ms |
3916 KB |
Output is correct |
34 |
Correct |
0 ms |
3916 KB |
Output is correct |
35 |
Correct |
0 ms |
3916 KB |
Output is correct |
36 |
Correct |
0 ms |
3916 KB |
Output is correct |
37 |
Correct |
0 ms |
3916 KB |
Output is correct |
38 |
Correct |
0 ms |
3916 KB |
Output is correct |
39 |
Correct |
0 ms |
3916 KB |
Output is correct |
40 |
Correct |
0 ms |
3916 KB |
Output is correct |
41 |
Correct |
43 ms |
3916 KB |
Output is correct |
42 |
Correct |
0 ms |
3916 KB |
Output is correct |
43 |
Correct |
13 ms |
3916 KB |
Output is correct |
44 |
Correct |
69 ms |
3916 KB |
Output is correct |
45 |
Correct |
69 ms |
3916 KB |
Output is correct |
46 |
Correct |
63 ms |
3916 KB |
Output is correct |
47 |
Correct |
66 ms |
3916 KB |
Output is correct |
48 |
Correct |
59 ms |
3916 KB |
Output is correct |
49 |
Correct |
66 ms |
3916 KB |
Output is correct |
50 |
Correct |
63 ms |
3916 KB |
Output is correct |
51 |
Correct |
63 ms |
3916 KB |
Output is correct |
52 |
Correct |
66 ms |
3916 KB |
Output is correct |
53 |
Correct |
66 ms |
3916 KB |
Output is correct |
54 |
Correct |
69 ms |
3916 KB |
Output is correct |
55 |
Correct |
66 ms |
3916 KB |
Output is correct |
56 |
Correct |
59 ms |
3916 KB |
Output is correct |
57 |
Correct |
63 ms |
3916 KB |
Output is correct |
58 |
Correct |
59 ms |
3916 KB |
Output is correct |
59 |
Correct |
19 ms |
3916 KB |
Output is correct |
60 |
Correct |
76 ms |
3916 KB |
Output is correct |
61 |
Correct |
53 ms |
3916 KB |
Output is correct |
62 |
Correct |
63 ms |
3916 KB |
Output is correct |
63 |
Correct |
63 ms |
3916 KB |
Output is correct |
64 |
Correct |
76 ms |
3916 KB |
Output is correct |
65 |
Correct |
66 ms |
3916 KB |
Output is correct |
66 |
Correct |
63 ms |
3916 KB |
Output is correct |
67 |
Correct |
59 ms |
3916 KB |
Output is correct |
68 |
Correct |
66 ms |
3916 KB |
Output is correct |
69 |
Correct |
69 ms |
3916 KB |
Output is correct |