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>
#define ll long long
using namespace std;
const int N = 1e6+10;
double A[N];
int n,k;
double T;
int ans;
bool check(double V){
int l = k - 1, r = k + 1;
double sl = 0, sr = 0;
double reserveT = T;
while(l>=1 || r<=n){
double s1 = (l>=1) ? A[k] - A[l] - sl : 1e9;
double s2 = (r<=n) ? A[r] - A[k] - sr : 1e9;
//cout<<sl<<" "<<sr<<endl;
if(s1 <= s2){
if(reserveT >= s1/(2*V)){
reserveT -= s1/(2*V);
reserveT += T;
sl += s1;
l--;
} else {
return false;
}
} else {
if(reserveT >= s2/(2*V)){
reserveT -= s2/(2*V);
reserveT += T;
sr += s2;
r++;
} else {
return false;
}
}
}
return true;
}
int main(){
cin>>n>>k>>T;
for(int i=1;i<=n;i++){
cin>>A[i];
}
int l = 1, r = 1e9;
while(l<=r){
int mid = (l+r)/2;
if(check(mid)){
ans = mid, r = mid-1;
} else {
l = mid+1;
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |