Submission #953906

#TimeUsernameProblemLanguageResultExecution timeMemory
9539064QT0RRice Hub (IOI11_ricehub)C++17
0 / 100
2 ms2648 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll pref[100003]; ll pos[100003]; ll cost(ll l, ll p){ ll med=(l+p)/2; return pref[p]-2*pref[med]+pos[l-1]+(!((l+p)&1))*pos[med]; } ll besthub(int n, int L, int x[], ll bud){ for (ll i = 0; i<n; i++){ pos[i+1]=x[i]; pref[i+1]=pref[i]+x[i]; } ll mx=1,p=1; for (ll l = 1; l<=n; l++){ while(p<n && cost(l,p+1)<=bud)p++; mx=max(mx,p-l+1); } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...