제출 #129980

#제출 시각아이디문제언어결과실행 시간메모리
129980VardanyanHacker (BOI15_hac)C++14
20 / 100
1068 ms504 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 500*1000+5;
int a[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];
    }
    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;
            }
            mx = max(mx,cur);
        }
        ans = max(ans,all-mx);
    }
    cout<<ans<<endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...