Submission #1019614

#TimeUsernameProblemLanguageResultExecution timeMemory
1019614LuvidiRice Hub (IOI11_ricehub)C++17
100 / 100
14 ms3420 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fs first #define sc second #define pb push_back int besthub(int n, int L, int X[], long long b) { ll a[n],ans=0,pre[n+1]; pre[0]=0; for(int i=0;i<n;i++){ a[i]=X[i]; pre[i+1]=pre[i]+a[i]; } for(int i=0;i<n;i++){ ll l=0,r=min(i,n-1-i); while(l<r){ ll m=(l+r+1)/2; if(pre[i+m+1]-pre[i+1]-(pre[i]-pre[i-m])<=b)l=m; else r=m-1; } ans=max(ans,2*l+1); l=0,r=min(i+1,n-1-i); while(l<r){ ll m=(l+r+1)/2; if(pre[i+m+1]-pre[i+1]-(pre[i+1]-pre[i-m+1])<=b)l=m; else r=m-1; } ans=max(ans,2*l); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...