#include <iostream>
using namespace std;
const long long maxN = 1e5 + 5, inf = 1e9;
long long arr[maxN];
int main(){
long long n, k, t;
cin >> n >> k >> t;
for (int i = 0; i < n; i++) cin >> arr[i];
k--;
long long l = 1, r = inf, ans = inf;
while(l <= r){
long long mid = (l+r)/2, left_margin = 0, right_margin = 0;
int left = k, right = k, pos = 1;
while(pos){
pos = 0;
if(left){
long long last = arr[k] - 2*(k-(left-1))*mid*t - left_margin;
if (last <= arr[left-1]){
left_margin = 0;
right_margin = arr[left-1] - last;
left--;
pos = 1;
}
}
if (right < n-1){
long long last = arr[k] + 2*(right+1 - k)*mid*t + right_margin;
if (last >= arr[right+1]){
right_margin = 0;
left_margin = last - arr[right+1];
right++;
pos = 1;
}
}
}
if (left == 0 && right == n-1){
ans = mid;
r = mid-1;
}
else l = mid+1;
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |