# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31594 | 2017-08-30T02:25:12 Z | huynd2001 | Hacker (BOI15_hac) | C++14 | 0 ms | 13732 KB |
/*huypheu 4 6 8 4 7 */ #include <bits/stdc++.h> #define int long long using namespace std; int a[500007]; int su[500007]; int sup[500007]; signed main() { int n; scanf("%lld",&n); for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); } int la=(n/2)+(n%2!=0); for(int i=1;i<=n;i++) { su[i]=su[i-1]+a[i]; } for(int i=1;i<=n;i++) { if(i+la-1<=n) { sup[i]=su[i+la-1]-su[i-1]; } else { sup[i]=su[n]-su[i-1]+su[n-i+1]; } } // for(int i=1;i<=n;i++) cout << sup[i] << endl; for(int i=n+1;i<=2*n;i++) { sup[i]=sup[i-n]; } deque <int> que; for(int i=1;i<=la;i++) { while(!que.empty() && sup[que.back()]>=sup[i]) que.pop_back(); que.push_back(i); } // cout << la << endl; int ans=sup[que.front()]; // cout << la << " " << que.front() << endl; for(int i=la+1;i<=la+n-1;i++) { // int k=(i%n-n)%n+n; while(!que.empty() && que.front()<i-la+1) que.pop_front(); // cout << que.back() << endl; while(!que.empty() && sup[que.back()]>=sup[i]) que.pop_back(); que.push_back(i); // cout << i << " " << que.front() << endl; ans=max(ans,sup[que.front()]); } printf("%lld",ans); // int mi=0; // for(int i=2;i<=n-la+1;i++) // { // mi=max(mi,su[i+la-1]-su[i-1]); // } // printf("%lld",su[n]-mi); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13732 KB | Output is correct |
2 | Correct | 0 ms | 13732 KB | Output is correct |
3 | Incorrect | 0 ms | 13732 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13732 KB | Output is correct |
2 | Correct | 0 ms | 13732 KB | Output is correct |
3 | Incorrect | 0 ms | 13732 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13732 KB | Output is correct |
2 | Incorrect | 0 ms | 13732 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13732 KB | Output is correct |
2 | Correct | 0 ms | 13732 KB | Output is correct |
3 | Incorrect | 0 ms | 13732 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |