Submission #101227

#TimeUsernameProblemLanguageResultExecution timeMemory
101227Leonardo_PaesHacker (BOI15_hac)C++11
60 / 100
135 ms4328 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5+10; int vet[MAXN], pref[MAXN]; int main(){ int n, k, resp=0x3f3f3f3f; cin >> n; k = ceil((double)n/2); for(int i=1; i<=n; i++){ cin >> vet[i]; pref[i]=vet[i]+pref[i-1]; } if(n>5000){ for(int i=1; i<=k; i++){ int sum=0; sum += pref[i]; sum += pref[n] - pref[n-(k-i)]; resp = min(resp,sum); } } else{ resp=0; for(int i=1; i<=n; i++){ int p=0x3f3f3f3f; for(int j=0; j<k; j++){ int sum=0, x=i+j; if(x>n)x-=n; if(x<=k){ sum+=pref[x]; sum+= pref[n] - pref[n-(k-x)]; } else{ sum+=pref[x] - pref[x-k]; } p = min(p,sum); } resp=max(resp,p); } } cout << resp << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...