# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
104605 | 2019-04-08T10:41:47 Z | teomrn | Hacker (BOI15_hac) | C++14 | 142 ms | 17736 KB |
#include <iostream> #include <stdio.h> #include <queue> #include <algorithm> using namespace std; struct MinHeap { priority_queue <int> added, removed; void add(int x) { added.push(-x); } void rem(int x) { removed.push(-x); } int top() { while (!removed.empty() && removed.top() == added.top()) removed.pop(), added.pop(); return -added.top(); } MinHeap() { added.push(-2e9); } } h; const int NMAX = 500010; int vals[NMAX]; int sp[2 * NMAX]; int ans[2 * NMAX]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", vals + i); sp[i] = sp[i + n] = vals[i]; } for (int i = 1; i < 2 * n; i++) sp[i] += sp[i - 1]; int l = (n + 1) / 2; fill(ans, ans + 2 * n, 2e9); for (int i = 0; i + l - 1 < 2 * n; i++) { int val = sp[i + l - 1] - (i ? sp[i - 1] : 0); h.add(val); ans[i] = h.top(); if (i >= l - 1) { int val = sp[i] - (i >= l ? sp[i - l] : 0); h.rem(val); } } int best = 0; for (int i = 0; i < n; i++) { int act = min(ans[i], ans[i + n]); best = max(best, act); } printf("%d\n", best); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 284 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 284 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 512 KB | Output is correct |
23 | Correct | 4 ms | 512 KB | Output is correct |
24 | Correct | 3 ms | 512 KB | Output is correct |
25 | Correct | 3 ms | 512 KB | Output is correct |
26 | Correct | 3 ms | 512 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 3 ms | 512 KB | Output is correct |
31 | Correct | 3 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 512 KB | Output is correct |
4 | Correct | 23 ms | 2684 KB | Output is correct |
5 | Correct | 64 ms | 6764 KB | Output is correct |
6 | Correct | 72 ms | 8364 KB | Output is correct |
7 | Correct | 70 ms | 10984 KB | Output is correct |
8 | Correct | 141 ms | 17636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 284 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 512 KB | Output is correct |
23 | Correct | 4 ms | 512 KB | Output is correct |
24 | Correct | 3 ms | 512 KB | Output is correct |
25 | Correct | 3 ms | 512 KB | Output is correct |
26 | Correct | 3 ms | 512 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 3 ms | 512 KB | Output is correct |
31 | Correct | 3 ms | 512 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 3 ms | 512 KB | Output is correct |
35 | Correct | 23 ms | 2684 KB | Output is correct |
36 | Correct | 64 ms | 6764 KB | Output is correct |
37 | Correct | 72 ms | 8364 KB | Output is correct |
38 | Correct | 70 ms | 10984 KB | Output is correct |
39 | Correct | 141 ms | 17636 KB | Output is correct |
40 | Correct | 5 ms | 768 KB | Output is correct |
41 | Correct | 7 ms | 1152 KB | Output is correct |
42 | Correct | 13 ms | 1536 KB | Output is correct |
43 | Correct | 56 ms | 8172 KB | Output is correct |
44 | Correct | 142 ms | 17640 KB | Output is correct |
45 | Correct | 24 ms | 3824 KB | Output is correct |
46 | Correct | 98 ms | 10932 KB | Output is correct |
47 | Correct | 142 ms | 17736 KB | Output is correct |
48 | Correct | 97 ms | 13680 KB | Output is correct |
49 | Correct | 96 ms | 17036 KB | Output is correct |
50 | Correct | 90 ms | 17200 KB | Output is correct |