# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129983 | 2019-07-13T17:19:57 Z | Vardanyan | Hacker (BOI15_hac) | C++14 | 3 ms | 380 KB |
#include <bits/stdc++.h> using namespace std; const int N = 500*1000+5; int a[N]; long long pref[N]; int main(){ ios_base::sync_with_stdio(false); int n; cin>>n; long long all = 0; for(int i = 1;i<=n;i++) { cin>>a[i]; all+=a[i]; pref[i] = pref[i-1]+a[i]; } long long ans = 0; for(int i = 1;i<=n;i++){ long long mx = 0; for(int j = 1;j<=n;j++){ int jj = j; int qn = 0; long long cur = 0; /*while(1){ if(jj == i) break; cur+=a[jj]; qn++; if(qn == n/2) break; jj++; if(jj>n) jj = 1; }*/ int l = j; int r = j+n/2-1; if(r>n) r = (n-r); if(r>=l){ if(i<l || i>r){ cur = pref[r]-pref[l-1]; } } else{ if(i>r && i<l){ cur+=(pref[r]); cur+=(pref[n]-pref[l-1]); } } mx = max(mx,cur); } ans = max(ans,all-mx); } cout<<ans<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |