답안 #55143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55143 2018-07-06T06:23:05 Z 노영훈(#1526) 도넛 (JOI14_ho_t3) C++11
50 / 100
2000 ms 2212 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int n, A[2*MX];
ll ans=0;

ll solve(int A[]){
    ll S[MX]={};
    for(int i=1; i<=n; i++) S[i]=S[i-1]+A[i];
    int s=0, e=n;
    while(s<e){
        int m=(s+e+1)/2;
        int ss=m, ee=n;
        while(ss<ee){
            int mm=(ss+ee)/2;
            if(S[mm]-S[m]>=S[m]) ee=mm;
            else ss=mm+1;
        }
        if(S[ss]-S[m]>=S[m] && S[n]-S[ss]>=S[m]) s=m;
        else e=m-1;
    }
    return S[s];
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i];
    for(int i=1; i<=n; i++){
        ans=max(ans, solve(A+i-1));
        A[i+n]=A[i];
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1144 KB Output is correct
2 Correct 8 ms 1144 KB Output is correct
3 Correct 7 ms 1196 KB Output is correct
4 Correct 8 ms 1196 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 8 ms 1320 KB Output is correct
7 Correct 7 ms 1352 KB Output is correct
8 Correct 7 ms 1360 KB Output is correct
9 Correct 8 ms 1468 KB Output is correct
10 Correct 7 ms 1468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1144 KB Output is correct
2 Correct 8 ms 1144 KB Output is correct
3 Correct 7 ms 1196 KB Output is correct
4 Correct 8 ms 1196 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 8 ms 1320 KB Output is correct
7 Correct 7 ms 1352 KB Output is correct
8 Correct 7 ms 1360 KB Output is correct
9 Correct 8 ms 1468 KB Output is correct
10 Correct 7 ms 1468 KB Output is correct
11 Correct 21 ms 1468 KB Output is correct
12 Correct 20 ms 1468 KB Output is correct
13 Correct 21 ms 1516 KB Output is correct
14 Correct 20 ms 1516 KB Output is correct
15 Correct 23 ms 1516 KB Output is correct
16 Correct 21 ms 1516 KB Output is correct
17 Correct 21 ms 1516 KB Output is correct
18 Correct 21 ms 1516 KB Output is correct
19 Correct 21 ms 1516 KB Output is correct
20 Correct 22 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1144 KB Output is correct
2 Correct 8 ms 1144 KB Output is correct
3 Correct 7 ms 1196 KB Output is correct
4 Correct 8 ms 1196 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 8 ms 1320 KB Output is correct
7 Correct 7 ms 1352 KB Output is correct
8 Correct 7 ms 1360 KB Output is correct
9 Correct 8 ms 1468 KB Output is correct
10 Correct 7 ms 1468 KB Output is correct
11 Correct 21 ms 1468 KB Output is correct
12 Correct 20 ms 1468 KB Output is correct
13 Correct 21 ms 1516 KB Output is correct
14 Correct 20 ms 1516 KB Output is correct
15 Correct 23 ms 1516 KB Output is correct
16 Correct 21 ms 1516 KB Output is correct
17 Correct 21 ms 1516 KB Output is correct
18 Correct 21 ms 1516 KB Output is correct
19 Correct 21 ms 1516 KB Output is correct
20 Correct 22 ms 1516 KB Output is correct
21 Correct 404 ms 1616 KB Output is correct
22 Correct 386 ms 1616 KB Output is correct
23 Correct 376 ms 1616 KB Output is correct
24 Correct 406 ms 1616 KB Output is correct
25 Correct 403 ms 1616 KB Output is correct
26 Correct 388 ms 1616 KB Output is correct
27 Correct 421 ms 1660 KB Output is correct
28 Correct 421 ms 1660 KB Output is correct
29 Correct 418 ms 1660 KB Output is correct
30 Correct 428 ms 1660 KB Output is correct
31 Correct 428 ms 1660 KB Output is correct
32 Correct 376 ms 1660 KB Output is correct
33 Correct 448 ms 1660 KB Output is correct
34 Correct 402 ms 1660 KB Output is correct
35 Correct 414 ms 1660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1144 KB Output is correct
2 Correct 8 ms 1144 KB Output is correct
3 Correct 7 ms 1196 KB Output is correct
4 Correct 8 ms 1196 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 8 ms 1320 KB Output is correct
7 Correct 7 ms 1352 KB Output is correct
8 Correct 7 ms 1360 KB Output is correct
9 Correct 8 ms 1468 KB Output is correct
10 Correct 7 ms 1468 KB Output is correct
11 Correct 21 ms 1468 KB Output is correct
12 Correct 20 ms 1468 KB Output is correct
13 Correct 21 ms 1516 KB Output is correct
14 Correct 20 ms 1516 KB Output is correct
15 Correct 23 ms 1516 KB Output is correct
16 Correct 21 ms 1516 KB Output is correct
17 Correct 21 ms 1516 KB Output is correct
18 Correct 21 ms 1516 KB Output is correct
19 Correct 21 ms 1516 KB Output is correct
20 Correct 22 ms 1516 KB Output is correct
21 Correct 404 ms 1616 KB Output is correct
22 Correct 386 ms 1616 KB Output is correct
23 Correct 376 ms 1616 KB Output is correct
24 Correct 406 ms 1616 KB Output is correct
25 Correct 403 ms 1616 KB Output is correct
26 Correct 388 ms 1616 KB Output is correct
27 Correct 421 ms 1660 KB Output is correct
28 Correct 421 ms 1660 KB Output is correct
29 Correct 418 ms 1660 KB Output is correct
30 Correct 428 ms 1660 KB Output is correct
31 Correct 428 ms 1660 KB Output is correct
32 Correct 376 ms 1660 KB Output is correct
33 Correct 448 ms 1660 KB Output is correct
34 Correct 402 ms 1660 KB Output is correct
35 Correct 414 ms 1660 KB Output is correct
36 Execution timed out 2069 ms 2212 KB Time limit exceeded
37 Halted 0 ms 0 KB -