답안 #86094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86094 2018-11-24T20:26:47 Z igzi Hacker (BOI15_hac) C++17
0 / 100
3 ms 856 KB
#include <bits/stdc++.h>
#define maxN 500005

using namespace std;

int seg[4*maxN],a[2*maxN],b[maxN],n,i,d,ans,sum;

void update(int n,int l,int d,int x,int y){
if(l==d) seg[n]=y;
else{
    int m=(l+d)/2;
    if(x<=m) update(2*n,l,m,x,y);
    else update(2*n+1,m+1,d,x,y);
    seg[n]=max(seg[2*n],seg[2*n+1]);
}
}
int query(int n,int l,int d,int x,int y){
if(d<x || l>y || x>y) return 0;
if(l>=x && y>=d) return seg[n];
int m=(l+d)/2;
return max(query(2*n,l,m,x,y),query(2*n+1,m+1,d,x,y));
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin>>n;
    d=n/2;
    for(i=0;i<n;i++) {cin>>a[i]; a[n+i]=a[i]; sum+=a[i];}
    for(i=0;i<d;i++) b[0]+=a[i];
    update(1,0,n-1,0,b[0]);
    for(i=1;i<n;i++) {b[i]=b[i-1]-a[i-1]+a[i+d-1]; update(1,0,n-1,i,b[i]);}
    for(i=0;i<n;i++){
        ans=max(ans,sum-max(query(1,0,n-1,0,i-d),query(1,0,n-1,i+1,n-1)));
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 3 ms 820 KB Output is correct
8 Correct 3 ms 820 KB Output is correct
9 Correct 2 ms 820 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 2 ms 836 KB Output is correct
12 Incorrect 2 ms 836 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 3 ms 820 KB Output is correct
8 Correct 3 ms 820 KB Output is correct
9 Correct 2 ms 820 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 2 ms 836 KB Output is correct
12 Incorrect 2 ms 836 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 3 ms 820 KB Output is correct
8 Correct 3 ms 820 KB Output is correct
9 Correct 2 ms 820 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 2 ms 836 KB Output is correct
12 Incorrect 2 ms 836 KB Output isn't correct
13 Halted 0 ms 0 KB -