# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30489 | 2017-07-24T00:03:01 Z | sampriti | Hacker (BOI15_hac) | C++14 | 766 ms | 18784 KB |
#include <cstdio> #include <algorithm> #include <set> using namespace std; int N; int A[500000]; int P[500000]; int sum[500000]; // sum[i..(i+len)] multiset<int> S; int query(int i, int j) { if(i > j) { return query(i, N - 1) + query(0, j); } if(i == 0) return P[j]; return P[j] - P[i - 1]; } int main() { scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%d", &A[i]); P[0] = A[0]; for(int i = 1; i < N; i++) P[i] = P[i - 1] + A[i]; int len = (N + 1)/2; for(int i = 0; i < N; i++) { sum[i] = query(i, (i + len - 1) % N); } int ans = 0; int L = 0 - (len - 1) + N, R = 0; int j = L; while(j != 1) { S.insert(sum[j]); j = (j + 1) % N; } for(int i = 0; i < N; i++) { ans = max(ans, *S.begin()); S.erase(S.find(sum[L])); L = (L + 1) % N; R = (R + 1) % N; S.insert(sum[R]); } printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7036 KB | Output is correct |
2 | Correct | 0 ms | 7036 KB | Output is correct |
3 | Correct | 0 ms | 7036 KB | Output is correct |
4 | Correct | 0 ms | 7036 KB | Output is correct |
5 | Correct | 0 ms | 7036 KB | Output is correct |
6 | Correct | 0 ms | 7036 KB | Output is correct |
7 | Correct | 0 ms | 7036 KB | Output is correct |
8 | Correct | 0 ms | 7036 KB | Output is correct |
9 | Correct | 0 ms | 7036 KB | Output is correct |
10 | Correct | 0 ms | 7036 KB | Output is correct |
11 | Correct | 0 ms | 7036 KB | Output is correct |
12 | Correct | 0 ms | 7036 KB | Output is correct |
13 | Correct | 0 ms | 7036 KB | Output is correct |
14 | Correct | 0 ms | 7036 KB | Output is correct |
15 | Correct | 0 ms | 7036 KB | Output is correct |
16 | Correct | 0 ms | 7036 KB | Output is correct |
17 | Correct | 0 ms | 7036 KB | Output is correct |
18 | Correct | 0 ms | 7036 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7036 KB | Output is correct |
2 | Correct | 0 ms | 7036 KB | Output is correct |
3 | Correct | 0 ms | 7036 KB | Output is correct |
4 | Correct | 0 ms | 7036 KB | Output is correct |
5 | Correct | 0 ms | 7036 KB | Output is correct |
6 | Correct | 0 ms | 7036 KB | Output is correct |
7 | Correct | 0 ms | 7036 KB | Output is correct |
8 | Correct | 0 ms | 7036 KB | Output is correct |
9 | Correct | 0 ms | 7036 KB | Output is correct |
10 | Correct | 0 ms | 7036 KB | Output is correct |
11 | Correct | 0 ms | 7036 KB | Output is correct |
12 | Correct | 0 ms | 7036 KB | Output is correct |
13 | Correct | 0 ms | 7036 KB | Output is correct |
14 | Correct | 0 ms | 7036 KB | Output is correct |
15 | Correct | 0 ms | 7036 KB | Output is correct |
16 | Correct | 0 ms | 7036 KB | Output is correct |
17 | Correct | 0 ms | 7036 KB | Output is correct |
18 | Correct | 0 ms | 7036 KB | Output is correct |
19 | Correct | 0 ms | 7036 KB | Output is correct |
20 | Correct | 0 ms | 7036 KB | Output is correct |
21 | Correct | 0 ms | 7036 KB | Output is correct |
22 | Correct | 0 ms | 7168 KB | Output is correct |
23 | Correct | 3 ms | 7168 KB | Output is correct |
24 | Correct | 0 ms | 7168 KB | Output is correct |
25 | Correct | 3 ms | 7168 KB | Output is correct |
26 | Correct | 3 ms | 7168 KB | Output is correct |
27 | Correct | 0 ms | 7036 KB | Output is correct |
28 | Correct | 0 ms | 7036 KB | Output is correct |
29 | Correct | 0 ms | 7036 KB | Output is correct |
30 | Correct | 0 ms | 7168 KB | Output is correct |
31 | Correct | 3 ms | 7168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7036 KB | Output is correct |
2 | Correct | 0 ms | 7036 KB | Output is correct |
3 | Correct | 3 ms | 7168 KB | Output is correct |
4 | Correct | 59 ms | 8884 KB | Output is correct |
5 | Correct | 203 ms | 11788 KB | Output is correct |
6 | Correct | 286 ms | 12976 KB | Output is correct |
7 | Correct | 296 ms | 14032 KB | Output is correct |
8 | Correct | 766 ms | 18784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7036 KB | Output is correct |
2 | Correct | 0 ms | 7036 KB | Output is correct |
3 | Correct | 0 ms | 7036 KB | Output is correct |
4 | Correct | 0 ms | 7036 KB | Output is correct |
5 | Correct | 0 ms | 7036 KB | Output is correct |
6 | Correct | 0 ms | 7036 KB | Output is correct |
7 | Correct | 0 ms | 7036 KB | Output is correct |
8 | Correct | 0 ms | 7036 KB | Output is correct |
9 | Correct | 0 ms | 7036 KB | Output is correct |
10 | Correct | 0 ms | 7036 KB | Output is correct |
11 | Correct | 0 ms | 7036 KB | Output is correct |
12 | Correct | 0 ms | 7036 KB | Output is correct |
13 | Correct | 0 ms | 7036 KB | Output is correct |
14 | Correct | 0 ms | 7036 KB | Output is correct |
15 | Correct | 0 ms | 7036 KB | Output is correct |
16 | Correct | 0 ms | 7036 KB | Output is correct |
17 | Correct | 0 ms | 7036 KB | Output is correct |
18 | Correct | 0 ms | 7036 KB | Output is correct |
19 | Correct | 0 ms | 7036 KB | Output is correct |
20 | Correct | 0 ms | 7036 KB | Output is correct |
21 | Correct | 0 ms | 7036 KB | Output is correct |
22 | Correct | 0 ms | 7168 KB | Output is correct |
23 | Correct | 3 ms | 7168 KB | Output is correct |
24 | Correct | 0 ms | 7168 KB | Output is correct |
25 | Correct | 3 ms | 7168 KB | Output is correct |
26 | Correct | 3 ms | 7168 KB | Output is correct |
27 | Correct | 0 ms | 7036 KB | Output is correct |
28 | Correct | 0 ms | 7036 KB | Output is correct |
29 | Correct | 0 ms | 7036 KB | Output is correct |
30 | Correct | 0 ms | 7168 KB | Output is correct |
31 | Correct | 3 ms | 7168 KB | Output is correct |
32 | Correct | 0 ms | 7036 KB | Output is correct |
33 | Correct | 0 ms | 7036 KB | Output is correct |
34 | Correct | 3 ms | 7168 KB | Output is correct |
35 | Correct | 59 ms | 8884 KB | Output is correct |
36 | Correct | 203 ms | 11788 KB | Output is correct |
37 | Correct | 286 ms | 12976 KB | Output is correct |
38 | Correct | 296 ms | 14032 KB | Output is correct |
39 | Correct | 766 ms | 18784 KB | Output is correct |
40 | Correct | 6 ms | 7300 KB | Output is correct |
41 | Correct | 6 ms | 7564 KB | Output is correct |
42 | Correct | 16 ms | 7696 KB | Output is correct |
43 | Correct | 226 ms | 11788 KB | Output is correct |
44 | Correct | 496 ms | 18784 KB | Output is correct |
45 | Correct | 99 ms | 9412 KB | Output is correct |
46 | Correct | 306 ms | 14032 KB | Output is correct |
47 | Correct | 673 ms | 18784 KB | Output is correct |
48 | Correct | 369 ms | 18784 KB | Output is correct |
49 | Correct | 326 ms | 18784 KB | Output is correct |
50 | Correct | 333 ms | 18784 KB | Output is correct |