답안 #789804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
789804 2023-07-22T04:58:33 Z UmairAhmadMirza Hacker (BOI15_hac) C++14
0 / 100
1 ms 340 KB
/*********************ALLAH HO AKBAR***********************/
/************HAZRAT MUHAMMAD (Peace be upon him)***********/


#include <bits/stdc++.h>
using namespace std;
#define int long long
int const N=1e6+5;
int pre[N];
int arr[N];
int n;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    int sm=0;
    for (int i = 1; i <=n; ++i){
        cin>>arr[i];
        sm+=arr[i];
    }
    for (int i = 1; i <=n; ++i)
        arr[i+n]=arr[i];
    int k=(n/2)+(n%2);
    for (int i = 1; i <=2*n; ++i)
        pre[i]=pre[i-1]+arr[i];
    vector<pair<int,int>> v;
    for (int i = 1; i <=n; ++i)
    {
        int chunk=pre[(i+k)-1]-pre[i-1];
        int chunk2=sm-chunk;
        if(chunk>=chunk2)
            v.push_back({chunk-chunk2,chunk});
    }
    sort(v.begin(), v.end());
    cout<<v[0].second<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -