Submission #84707

# Submission time Handle Problem Language Result Execution time Memory
84707 2018-11-16T20:10:54 Z rzbt Hacker (BOI15_hac) C++14
100 / 100
520 ms 37252 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 500005
typedef long long ll;


using namespace std;
int n;
int niz[MAXN+MAXN];
int zbir[MAXN];

multiset<int> s;
int res=0;
int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        int t;
        scanf("%d", &t);
        niz[i]=niz[n+i]=t;
    }
    for(int i=1;i<=n/2+(n&1);i++){
        zbir[1]+=niz[i];
    }
    for(int i=2;i<=n;i++){
        zbir[i]=zbir[i-1]+niz[i+n/2+(n&1)-1]-niz[i-1];
    }
    //printf("ok ");
    for(int i=1;i<=n/2+(n&1);i++){
        s.insert(zbir[i]);

    }
    //printf("this ");
    res=*s.begin();
    for(int i=2;i<=n;i++){

        s.erase(s.find(zbir[i-1]));
        s.insert(zbir[(i+n/2+(n&1)-2)%n+1]);
        res=max(res,*s.begin());
    }
    printf("%d",res);

    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
hac.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &t);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 2 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 2 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
19 Correct 2 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 3 ms 828 KB Output is correct
23 Correct 5 ms 964 KB Output is correct
24 Correct 3 ms 1004 KB Output is correct
25 Correct 5 ms 1032 KB Output is correct
26 Correct 5 ms 1056 KB Output is correct
27 Correct 2 ms 1056 KB Output is correct
28 Correct 2 ms 1056 KB Output is correct
29 Correct 2 ms 1056 KB Output is correct
30 Correct 4 ms 1104 KB Output is correct
31 Correct 4 ms 1184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1184 KB Output is correct
2 Correct 2 ms 1184 KB Output is correct
3 Correct 4 ms 1264 KB Output is correct
4 Correct 59 ms 4324 KB Output is correct
5 Correct 147 ms 9312 KB Output is correct
6 Correct 208 ms 12264 KB Output is correct
7 Correct 252 ms 15400 KB Output is correct
8 Correct 502 ms 24576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 2 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
19 Correct 2 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 3 ms 828 KB Output is correct
23 Correct 5 ms 964 KB Output is correct
24 Correct 3 ms 1004 KB Output is correct
25 Correct 5 ms 1032 KB Output is correct
26 Correct 5 ms 1056 KB Output is correct
27 Correct 2 ms 1056 KB Output is correct
28 Correct 2 ms 1056 KB Output is correct
29 Correct 2 ms 1056 KB Output is correct
30 Correct 4 ms 1104 KB Output is correct
31 Correct 4 ms 1184 KB Output is correct
32 Correct 2 ms 1184 KB Output is correct
33 Correct 2 ms 1184 KB Output is correct
34 Correct 4 ms 1264 KB Output is correct
35 Correct 59 ms 4324 KB Output is correct
36 Correct 147 ms 9312 KB Output is correct
37 Correct 208 ms 12264 KB Output is correct
38 Correct 252 ms 15400 KB Output is correct
39 Correct 502 ms 24576 KB Output is correct
40 Correct 7 ms 24576 KB Output is correct
41 Correct 13 ms 24576 KB Output is correct
42 Correct 19 ms 24576 KB Output is correct
43 Correct 172 ms 24576 KB Output is correct
44 Correct 471 ms 27944 KB Output is correct
45 Correct 71 ms 27944 KB Output is correct
46 Correct 244 ms 27944 KB Output is correct
47 Correct 520 ms 31924 KB Output is correct
48 Correct 352 ms 34116 KB Output is correct
49 Correct 336 ms 35804 KB Output is correct
50 Correct 338 ms 37252 KB Output is correct