Submission #990356

#TimeUsernameProblemLanguageResultExecution timeMemory
990356amine_arouaSparklers (JOI17_sparklers)C++17
0 / 100
1 ms472 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") using namespace std; #define int long long #define pb push_back #define nl '\n' #define fore(i, y) for(int i = 0; i < y; i++) #define forr(i, x, y) for(int i = x;i<=y;i++) #define forn(i, y, x) for(int i = y; i >= x; i--) const int N = 1e5 + 10; int n , k , t; int x[N]; bool check(int s) { vector<int> a , b; forn(i , k , 1) a.pb(x[i] - 2*t*s * i); forr(i , k , n) b.pb(x[i] - 2*t*s * i); int mx = a[0] , mn = b[0]; int i = 1 , j = 1; while(true) { if(i < (int)a.size() && a[i] >= mn) mx = max(mx , a[i++]); else if(j < (int)b.size() && b[j] <= mx) mn = min(mn , b[j++]); else break; } return (i == (int)a.size() && j == (int)b.size()); } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k>>t; bool acc = 1; forr(i , 1 , n) { cin >> x[i]; if (x[i] != 0) acc = 0; } if(acc) { cout<<0<<nl; return 0; } int lo = 0 , hi = 1e10; while(lo + 1 < hi) { int mid = (lo + hi)/2; if(check(mid)) hi = mid; else lo = mid; } cout<<hi<<nl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...