제출 #1139268

#제출 시각아이디문제언어결과실행 시간메모리
1139268buzdiHacker (BOI15_hac)C++17
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define ll long long
#define ld long double

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int NMAX = 5e5;
const int INF = 2e9;

int n, k;
int s, answer;
int a[2 * NMAX + 1];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[n + i] = a[i];
    }
    k = n / 2 + n % 2;

    answer = INF;
    for(int i = n + 1 - k + 1; i - k + 1 <= n; i++) {
        s += a[i];
        if(i >= n + 1) {
            answer = min(answer, s);
            s -= a[i - k + 1];
        }
    }
    cout << answer << '\n';

    return 0;
}

/*
    7 6 8 4 5 5 7 6 8 4 5 5 
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...