Submission #97089

# Submission time Handle Problem Language Result Execution time Memory
97089 2019-02-13T19:34:49 Z dalgerok Hacker (BOI15_hac) C++14
0 / 100
2 ms 384 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 2e6 + 5;



int n, m, sum, a[N], b[N];




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i + n] = a[i + 2 * n] = a[i];
    }
    m = (n + 1) / 2;
    sum = 0;
    for(int i = 1; i <= n; i++){
        sum += a[i];
        if(i > m){
            sum -= a[i - m];
        }
        b[i] = sum;
    }
    deque < int > q;
    int ans = 0;
    for(int i = 1; i <= 3 * n; i++){
        while(!q.empty() && b[q.back()] >= b[i]){
            q.pop_back();
        }
        q.push_back(i);
        if(q.front() + m <= i){
            q.pop_front();
        }
        ans = max(ans, b[q.front()]);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -