답안 #485797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485797 2021-11-09T11:54:21 Z radal Hacker (BOI15_hac) C++14
100 / 100
312 ms 18404 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC target("avx2,fma")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<long double,long double> pld;
const long long int N = 5e5+10,mod = 1e9+7,inf = 1e9,sq = 500;
inline int mkay(int a,int b){
    if (a+b >= mod) return a+b-mod;
    if (a+b < 0) return a+b+mod;
    return a+b;
}
inline int poww(int n,ll k){
    int c = 1;
    while (k){
        if (k&1) c = (1ll*c*n)%mod;
        n = (1ll*n*n)%mod;
        k >>= 1;
    }
    return c;
}
int a[N],pre[N];
int main(){
    ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,sum = 0;
    cin >> n;
    rep(i,0,n) cin >> a[i],sum+=a[i];
    int ans = inf+10;
    repr(i,n/2-1,0) pre[n/2-1] += a[i];
    rep(i,n/2,n)
        pre[i] = pre[i-1]+a[i]-a[i-n/2];
    repr(i,n/2-2,0)
        pre[i] = pre[i+1]-a[i+1]+a[n-(n/2-1-i)];
    set<pll> st;
    rep(i,1,(n+1)/2+1){
        st.insert({pre[i-1+n/2],i});
        ans = min(ans,sum-pre[i-1+n/2]);
    }
    int ind = (n+1)/2+1;
    rep(i,1,n){
        st.erase({pre[(i-1+n/2)%n],i});
        st.insert({pre[i-1],ind});
        ind ++;
        if (ind >= n) ind -= n;
        ans = max(ans,sum-st.rbegin()->X);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 516 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 33 ms 3084 KB Output is correct
5 Correct 103 ms 7328 KB Output is correct
6 Correct 149 ms 9228 KB Output is correct
7 Correct 151 ms 11000 KB Output is correct
8 Correct 307 ms 18052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 516 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 33 ms 3084 KB Output is correct
36 Correct 103 ms 7328 KB Output is correct
37 Correct 149 ms 9228 KB Output is correct
38 Correct 151 ms 11000 KB Output is correct
39 Correct 307 ms 18052 KB Output is correct
40 Correct 5 ms 588 KB Output is correct
41 Correct 9 ms 972 KB Output is correct
42 Correct 13 ms 1412 KB Output is correct
43 Correct 113 ms 7444 KB Output is correct
44 Correct 275 ms 18128 KB Output is correct
45 Correct 46 ms 3776 KB Output is correct
46 Correct 159 ms 10964 KB Output is correct
47 Correct 312 ms 18184 KB Output is correct
48 Correct 260 ms 18404 KB Output is correct
49 Correct 209 ms 17604 KB Output is correct
50 Correct 208 ms 17532 KB Output is correct