답안 #31593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31593 2017-08-30T02:24:21 Z minhtung0404 Hacker (BOI15_hac) C++14
0 / 100
0 ms 17640 KB
#include<bits/stdc++.h>
const int N = 5e5 + 5;
using namespace std;

deque <long long> mq;
long long n, a[2*N], sum[2*N], maxx, siz;

int main(){
    cin >> n;
    siz = (n+1)/2;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) a[i+n] = a[i];
    for (int i = 1; i <= siz; i++) sum[1] += a[i];
    for (int i = 2; i <= n; i++) sum[i] = sum[i-1] + a[i-1+siz] - a[i-1];
    for (int i = 1; i <= n; i++) sum[n+i] = sum[i];
    for (int i = 1; i <= 2*n; i++){
        while(mq.size() && sum[mq.front()] >= sum[i]) mq.pop_front();
        mq.push_front(i);
        if (i - mq.back() == siz) mq.pop_back();
        maxx = max(sum[mq.back()], maxx);
    }
    cout << maxx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17640 KB Output is correct
2 Correct 0 ms 17640 KB Output is correct
3 Incorrect 0 ms 17640 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17640 KB Output is correct
2 Correct 0 ms 17640 KB Output is correct
3 Incorrect 0 ms 17640 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17640 KB Output is correct
2 Incorrect 0 ms 17640 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17640 KB Output is correct
2 Correct 0 ms 17640 KB Output is correct
3 Incorrect 0 ms 17640 KB Output isn't correct
4 Halted 0 ms 0 KB -