Submission #42647

# Submission time Handle Problem Language Result Execution time Memory
42647 2018-03-01T20:03:54 Z XmtosX Hacker (BOI15_hac) C++14
100 / 100
575 ms 35124 KB
#include <bits/stdc++.h>
using namespace std;
int n,v[500005],here[500005],ans;
set <pair<int,int> > s;
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&v[i]);
    int k= (n/2)+(n%2),cur=0;
    for (int i=0;i<k;i++)
        cur+=v[i];
    for (int i=0;i<n;i++)
    {
        int j= (i+k)%n;
        cur-=v[i];
        cur+=v[j];
        here[(i+1)%n]=cur;
    }
    for (int i=0;i<k;i++)
        s.insert({here[i],i});
    for (int i=0;i<n;i++)
    {
        int j= (i+k)%n;
        s.erase({here[i],i});
        s.insert({here[j],j});
        ans=max(ans,s.begin()->first);
    }
    cout <<ans;
    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:7:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
hac.cpp:9:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&v[i]);
                          ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 1 ms 764 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 780 KB Output is correct
18 Correct 2 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 1 ms 764 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 780 KB Output is correct
18 Correct 2 ms 780 KB Output is correct
19 Correct 2 ms 788 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 800 KB Output is correct
22 Correct 3 ms 804 KB Output is correct
23 Correct 5 ms 948 KB Output is correct
24 Correct 3 ms 948 KB Output is correct
25 Correct 4 ms 1000 KB Output is correct
26 Correct 6 ms 1092 KB Output is correct
27 Correct 1 ms 1092 KB Output is correct
28 Correct 1 ms 1092 KB Output is correct
29 Correct 2 ms 1092 KB Output is correct
30 Correct 3 ms 1092 KB Output is correct
31 Correct 4 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 4 ms 1132 KB Output is correct
4 Correct 48 ms 3860 KB Output is correct
5 Correct 151 ms 8480 KB Output is correct
6 Correct 202 ms 11072 KB Output is correct
7 Correct 252 ms 13992 KB Output is correct
8 Correct 552 ms 22580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 1 ms 764 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 780 KB Output is correct
18 Correct 2 ms 780 KB Output is correct
19 Correct 2 ms 788 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 800 KB Output is correct
22 Correct 3 ms 804 KB Output is correct
23 Correct 5 ms 948 KB Output is correct
24 Correct 3 ms 948 KB Output is correct
25 Correct 4 ms 1000 KB Output is correct
26 Correct 6 ms 1092 KB Output is correct
27 Correct 1 ms 1092 KB Output is correct
28 Correct 1 ms 1092 KB Output is correct
29 Correct 2 ms 1092 KB Output is correct
30 Correct 3 ms 1092 KB Output is correct
31 Correct 4 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 4 ms 1132 KB Output is correct
35 Correct 48 ms 3860 KB Output is correct
36 Correct 151 ms 8480 KB Output is correct
37 Correct 202 ms 11072 KB Output is correct
38 Correct 252 ms 13992 KB Output is correct
39 Correct 552 ms 22580 KB Output is correct
40 Correct 7 ms 22580 KB Output is correct
41 Correct 13 ms 22580 KB Output is correct
42 Correct 18 ms 22580 KB Output is correct
43 Correct 154 ms 22580 KB Output is correct
44 Correct 453 ms 25832 KB Output is correct
45 Correct 64 ms 25832 KB Output is correct
46 Correct 258 ms 25832 KB Output is correct
47 Correct 575 ms 29648 KB Output is correct
48 Correct 370 ms 32076 KB Output is correct
49 Correct 358 ms 33752 KB Output is correct
50 Correct 388 ms 35124 KB Output is correct