답안 #153908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153908 2019-09-17T12:35:29 Z mhy908 도넛 (JOI14_ho_t3) C++14
100 / 100
136 ms 2040 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n;
LL arr[200010], maxx, ans;
LL f(int stnum, int st, int fin)
{
    if(st==fin)return arr[st]-arr[stnum];
    LL mid=(st+fin)/2+1;
    LL l=arr[mid]-arr[stnum];
    int next=lower_bound(arr+mid+1, arr+stnum+n, l+arr[mid])-arr;
    if(arr[stnum+n]-arr[next]>=l)return f(stnum, mid, fin);
    return f(stnum, st, mid-1);
}
bool ch(int stnum)
{
    LL l=arr[stnum+1]-arr[stnum];
    int next=lower_bound(arr+stnum+2, arr+stnum+n, l+arr[stnum+1])-arr;
    if(arr[stnum+n]-arr[next]>=l)return true;
    return false;
}
int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        LL temp;
        scanf("%lld", &temp);
        arr[i]=arr[i-1]+temp;
    }
    maxx=arr[n];
    for(int i=1; i<=n; i++){
        arr[i+n]=arr[i]+maxx;
    }
    for(int i=0; i<n; i++){
        if(ch(i))ans=max(ans, f(i, i+1, i+n-1));
    }
    printf("%lld", ans);
}

Compilation message

2014_ho_t3.cpp: In function 'int main()':
2014_ho_t3.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
2014_ho_t3.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &temp);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 9 ms 380 KB Output is correct
22 Correct 9 ms 376 KB Output is correct
23 Correct 9 ms 504 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 9 ms 524 KB Output is correct
26 Correct 9 ms 376 KB Output is correct
27 Correct 9 ms 376 KB Output is correct
28 Correct 9 ms 376 KB Output is correct
29 Correct 10 ms 504 KB Output is correct
30 Correct 9 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 8 ms 504 KB Output is correct
34 Correct 8 ms 504 KB Output is correct
35 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 9 ms 380 KB Output is correct
22 Correct 9 ms 376 KB Output is correct
23 Correct 9 ms 504 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 9 ms 524 KB Output is correct
26 Correct 9 ms 376 KB Output is correct
27 Correct 9 ms 376 KB Output is correct
28 Correct 9 ms 376 KB Output is correct
29 Correct 10 ms 504 KB Output is correct
30 Correct 9 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 8 ms 504 KB Output is correct
34 Correct 8 ms 504 KB Output is correct
35 Correct 8 ms 376 KB Output is correct
36 Correct 136 ms 1800 KB Output is correct
37 Correct 132 ms 1912 KB Output is correct
38 Correct 128 ms 2040 KB Output is correct
39 Correct 132 ms 1912 KB Output is correct
40 Correct 132 ms 2040 KB Output is correct
41 Correct 133 ms 1912 KB Output is correct
42 Correct 132 ms 1852 KB Output is correct
43 Correct 133 ms 1924 KB Output is correct
44 Correct 132 ms 1912 KB Output is correct
45 Correct 135 ms 1920 KB Output is correct
46 Correct 116 ms 1912 KB Output is correct
47 Correct 116 ms 2016 KB Output is correct
48 Correct 116 ms 2040 KB Output is correct