Submission #589680

#TimeUsernameProblemLanguageResultExecution timeMemory
589680penguinhackerHacker (BOI15_hac)C++17
40 / 100
1093 ms2388 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=5e5; int n, a[2*mxN], p[2*mxN+1], val[2*mxN+1]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; ++i) { cin >> a[i]; a[i+n]=a[i]; } for (int i=0; i<2*n; ++i) p[i+1]=p[i]+a[i]; for (int i=1; i+n/2<=2*n; ++i) val[i]=p[i+n/2]-p[i]; int ans=0; /*for (int rep=0; rep<n; ++rep) { for (int i=0; i<n; ++i) p[i+1]=p[i]+a[i]; int mx=0; for (int j=1; j+n/2-1<n; ++j) mx=max(mx, p[j+n/2]-p[j]); ans=max(ans, p[n]-mx); rotate(a, a+1, a+n); }*/ for (int i=0; i<n; ++i) { int mx=0; for (int j=1; j<=(n+1)/2; ++j) mx=max(mx, val[i+j]); ans=max(ans, p[n]-mx); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...