Submission #32318

#TimeUsernameProblemLanguageResultExecution timeMemory
32318dqhungdlHacker (BOI15_hac)C++14
100 / 100
743 ms17672 KiB
#include <bits/stdc++.h> using namespace std; int n,sum=0,res=0,a[1000005]; multiset<int> s; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; a[i+n]=a[i]; sum+=a[i]; } for(int i=1;i<=2*n;i++) a[i]+=a[i-1]; int k=n/2; for(int i=k;i<n;i++) s.insert(a[i]-a[i-k]); for(int i=1;i<=n;i++) { s.erase(s.find(a[i+k-1]-a[i-1])); s.insert(a[i+n-1]-a[i+n-1-k]); res=max(res,sum-*s.rbegin()); } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...