Submission #1099528

#TimeUsernameProblemLanguageResultExecution timeMemory
1099528KasymKRice Hub (IOI11_ricehub)C++17
68 / 100
1020 ms1076 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 1e5+5; ll par[N]; int besthub(int r, int l, int x[], ll b){ par[0] = 0; for(int i = 1; i <= r; ++i) par[i] = par[i-1]+x[i-1]; auto eday = [&](int s, int t) -> ll { int p = (s+t)>>1; ll wow = (p-s)*x[p]-(par[p]-par[s])+(par[t+1]-par[p+1])-(t-p)*x[p]; return wow; }; auto calc = [&](int k) -> bool { deque<int> dq; for(int i = 0; i <= k; ++i) dq.pb(i); int s = dq.front(), t = dq.back(); bool done = 0; done |= eday(s, t) <= b; for(int i = k+1; i < r and !done; ++i) dq.pop_front(), dq.pb(i), s = dq.front(), t = dq.back(), done |= eday(s, t) <= b; return done; }; int answer = -1; for(int k = 0; k < r; ++k) if(calc(k)) umax(answer, k+1); return answer; } // const int NN = 10; // int v[NN]; // int main(){ // v[0] = 1, v[1] = 2, v[2] = 10, v[3] = 12, v[4] = 14; // int answer = besthub(5, 20, v, 6); // printf("%d\n", answer); // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...