#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef long long ll;
#define int ll
const int N = 1e5 + 5;
int x[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, k, T; cin >> n >> k >> T;
for(int i=1;i<=n;i++){
cin >> x[i];
}
x[n + 1] = x[n];
auto check = [&](int s){
int t = T * s * 2;
int l = k, r = k, rem = t;
while(1 < l || r < n){
if(r == n || (1 < l && x[l] - x[l-1] <= x[r + 1] - x[r])){
if(rem < (x[l] - x[l-1])) return false;
rem -= (x[l] - x[l-1]);
rem += t; l--;
} else {
if(rem < (x[r + 1] - x[r])) return false;
rem -= (x[r + 1] - x[r]);
rem += t; r++;
}
if(rem > 1e18) rem = 1e18;
}
return true;
};
int l = 0, r = 1e9;
while(l < r){
int m = (l + r) >> 1;
if(check(m)) r = m;
else l = m + 1;
}
cout<<l<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |