답안 #1100970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100970 2024-10-15T06:30:24 Z Kodik Hacker (BOI15_hac) C++17
0 / 100
1 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
#define int ll
int mod = 998244353; 


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int k = n/2 + n%2;
    vector<int> arr(2*n);
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        arr[i] = arr[n+i] = x;
    }
    vector<pair<int,int>> sliding(n, {0,0});
    int sum = 0;
    for(int i = 0, j = 0; i < n; ++i){
        while(j-i<k){
            sum += arr[j];
            ++j;
        }
        sliding[i].ff = sum;
        sum -= arr[i];
    }
    reverse(arr.begin(), arr.end());
    sum = 0;
    for(int i = 0, j = 0; i < n; ++i){
        while(j-i<k){
            sum += arr[j];
            ++j;
        }
        sliding[n-i-1].ss = sum;
        sum -= arr[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans = max(ans, min(sliding[i].ff, sliding[i].ss));
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 476 KB Output is correct
2 Incorrect 1 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 476 KB Output is correct
2 Incorrect 1 ms 504 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 476 KB Output is correct
2 Incorrect 1 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -