Submission #103038

# Submission time Handle Problem Language Result Execution time Memory
103038 2019-03-28T19:58:51 Z pavel Hacker (BOI15_hac) C++14
100 / 100
687 ms 18468 KB
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

const int MAXN = 500005;

int n,k;
int a[MAXN];
int sum[MAXN];

int main(){
    scanf("%d", &n);
    k=(n+1)/2;
    for(int i=0;i<n;++i) scanf("%d", &a[i]);
    for(int i=0;i<k;++i) sum[0]+=a[i];
    for(int i=1;i<n;++i){
        sum[i]=sum[i-1]-a[i-1]+a[(i+k-1+n)%n];
    }
    multiset<int> s;
    for(int i=0;i<k;++i) s.insert(sum[i]);
    int sol=*s.begin();
    int t = n;
    for(int i=k;t;t--,i=(i+1)%n){
        s.insert(sum[i]);
        s.erase(s.lower_bound(sum[(i-k+n)%n]));
        sol=max(sol, *s.begin());
    }
    printf("%d", sol);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
hac.cpp:16:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;++i) scanf("%d", &a[i]);
                          ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 428 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 304 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 428 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 304 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 256 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 4 ms 520 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 4 ms 524 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 356 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 42 ms 2860 KB Output is correct
5 Correct 177 ms 6616 KB Output is correct
6 Correct 262 ms 8180 KB Output is correct
7 Correct 275 ms 9740 KB Output is correct
8 Correct 687 ms 16100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 428 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 304 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 256 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 4 ms 520 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 4 ms 524 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 356 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 5 ms 504 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 4 ms 512 KB Output is correct
35 Correct 42 ms 2860 KB Output is correct
36 Correct 177 ms 6616 KB Output is correct
37 Correct 262 ms 8180 KB Output is correct
38 Correct 275 ms 9740 KB Output is correct
39 Correct 687 ms 16100 KB Output is correct
40 Correct 5 ms 632 KB Output is correct
41 Correct 11 ms 996 KB Output is correct
42 Correct 23 ms 1448 KB Output is correct
43 Correct 173 ms 7520 KB Output is correct
44 Correct 521 ms 18204 KB Output is correct
45 Correct 57 ms 3832 KB Output is correct
46 Correct 222 ms 11132 KB Output is correct
47 Correct 524 ms 18192 KB Output is correct
48 Correct 311 ms 18468 KB Output is correct
49 Correct 308 ms 17588 KB Output is correct
50 Correct 315 ms 17588 KB Output is correct