Submission #559993

#TimeUsernameProblemLanguageResultExecution timeMemory
559993amunduzbaevSparklers (JOI17_sparklers)C++17
0 / 100
1 ms212 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int long long const int inf = 1e9 + 5; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k, t; cin>>n>>k>>t; vector<int> a(n), d(n); for(int i=0;i<n;i++) cin>>a[i], a[i] *= 2; for(int i=1;i<n;i++){ d[i] = a[i] - a[i-1]; } k--; auto check = [&](int s){ int l = k, r = k, pos = t * s; while(l || r+1<n){ int dl = inf, dr = inf; if(l) dl = d[l]; if(r+1<n) dr = d[r+1]; if(dl <= dr){ dl /= 2; if(dl > pos) return false; pos = pos - dl + t * s, l--; } else { dr /= 2; if(dr > pos) return false; pos = pos - dr + t * s, r++; } } return true; }; int l = 0, r = 2 * inf; while(l < r){ int m = (l + r) >> 1; if(check(m)) r = m; else l = m + 1; } cout<<(l+1) / 2<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...