This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++;
}
}
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |