Submission #157758

#TimeUsernameProblemLanguageResultExecution timeMemory
157758giorgikobSparklers (JOI17_sparklers)C++14
0 / 100
2 ms504 KiB
#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/2; l--; } else { return false; } } else { if(reserveT >= s2/(2*V)){ reserveT -= s2/(2*V); reserveT += T; sr += s2/2; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...