Submission #1071861

#TimeUsernameProblemLanguageResultExecution timeMemory
1071861LIFRice Hub (IOI11_ricehub)C++14
100 / 100
18 ms7772 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; long long int a[300005]; long long int su[300005]; long long int cal(int ll,int rr) { int len = rr - ll +1; if(len %2 == 0) { int suf = (ll+rr+1) / 2; long long int ans = su[rr] - su[suf-1] - su[suf-1] + su[ll-1]; return ans; } else { int mid = (ll+rr)/2; long long int ans = su[rr] - su[mid] - su[mid-1] + su[ll-1]; return ans; } } int besthub(int R, int L, int X[], long long B) { for(int i=1;i<=R;i++)a[i] = X[i-1]; for(int i=1;i<=R;i++)su[i] = su[i-1] + a[i]; int l = 1; int r = 1; int maxnlen = -1; while(r<=R) { if(cal(l,r) > B)l++; else { maxnlen = max(maxnlen,r-l+1); r++; } } return maxnlen; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...