Submission #671451

#TimeUsernameProblemLanguageResultExecution timeMemory
671451amunduzbaevSparklers (JOI17_sparklers)C++17
0 / 100
1 ms328 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...