# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43769 | 2018-03-23T04:20:29 Z | PowerOfNinjaGo | Hacker (BOI15_hac) | C++14 | 96 ms | 32504 KB |
//Power Of Ninja Go #include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vii vector< ii > #define pb push_back const int maxn = 5e5+5; int arr[2*maxn]; int qs[2*maxn]; int s[2*maxn]; int main() { //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif int n; scanf("%d", &n); for(int i = 1; i<= n; i++) scanf("%d", arr+i); for(int i = 1; i<= n; i++) arr[n+i] = arr[i]; for(int i = 1; i<= 2*n; i++) qs[i] = qs[i-1]+arr[i]; int k = n/2; for(int i = 1; i+k-1<= 2*n; i++) s[i] = qs[i+k-1]-qs[i-1]; int best = 2e9; deque< ii > dq; for(int i = 2; i< n-k+1; i++) { while(!dq.empty() && dq.back().X<= s[i]) dq.pop_back(); dq.push_back(ii(s[i], i)); } for(int i = 1; i<= n; i++) { while(!dq.empty() && dq.back().X<= s[n-k+i]) dq.pop_back(); dq.push_back(ii(s[n-k+i], n-k+i)); while(!dq.empty() && dq.front().Y<= i) dq.pop_front(); best = min(best, dq.front().X); } printf("%d\n", qs[n]-best); }
Compilation message
# | 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 | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 1 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 616 KB | Output is correct |
7 | Correct | 1 ms | 624 KB | Output is correct |
8 | Correct | 1 ms | 624 KB | Output is correct |
9 | Correct | 1 ms | 644 KB | Output is correct |
10 | Correct | 1 ms | 648 KB | Output is correct |
11 | Correct | 1 ms | 652 KB | Output is correct |
12 | Correct | 1 ms | 656 KB | Output is correct |
13 | Correct | 1 ms | 748 KB | Output is correct |
14 | Correct | 1 ms | 752 KB | Output is correct |
15 | Correct | 1 ms | 776 KB | Output is correct |
16 | Correct | 1 ms | 780 KB | Output is correct |
17 | Correct | 1 ms | 784 KB | Output is correct |
18 | Correct | 1 ms | 788 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 | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 1 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 616 KB | Output is correct |
7 | Correct | 1 ms | 624 KB | Output is correct |
8 | Correct | 1 ms | 624 KB | Output is correct |
9 | Correct | 1 ms | 644 KB | Output is correct |
10 | Correct | 1 ms | 648 KB | Output is correct |
11 | Correct | 1 ms | 652 KB | Output is correct |
12 | Correct | 1 ms | 656 KB | Output is correct |
13 | Correct | 1 ms | 748 KB | Output is correct |
14 | Correct | 1 ms | 752 KB | Output is correct |
15 | Correct | 1 ms | 776 KB | Output is correct |
16 | Correct | 1 ms | 780 KB | Output is correct |
17 | Correct | 1 ms | 784 KB | Output is correct |
18 | Correct | 1 ms | 788 KB | Output is correct |
19 | Correct | 1 ms | 792 KB | Output is correct |
20 | Correct | 2 ms | 800 KB | Output is correct |
21 | Correct | 2 ms | 800 KB | Output is correct |
22 | Correct | 2 ms | 804 KB | Output is correct |
23 | Correct | 2 ms | 948 KB | Output is correct |
24 | Correct | 2 ms | 948 KB | Output is correct |
25 | Correct | 2 ms | 1000 KB | Output is correct |
26 | Correct | 2 ms | 1040 KB | Output is correct |
27 | Correct | 1 ms | 1040 KB | Output is correct |
28 | Correct | 1 ms | 1040 KB | Output is correct |
29 | Correct | 1 ms | 1040 KB | Output is correct |
30 | Correct | 2 ms | 1076 KB | Output is correct |
31 | Correct | 2 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 | 2 ms | 1240 KB | Output is correct |
4 | Correct | 25 ms | 3184 KB | Output is correct |
5 | Correct | 34 ms | 6452 KB | Output is correct |
6 | Correct | 45 ms | 8644 KB | Output is correct |
7 | Correct | 54 ms | 11156 KB | Output is correct |
8 | Correct | 87 ms | 17548 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 | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 1 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 616 KB | Output is correct |
7 | Correct | 1 ms | 624 KB | Output is correct |
8 | Correct | 1 ms | 624 KB | Output is correct |
9 | Correct | 1 ms | 644 KB | Output is correct |
10 | Correct | 1 ms | 648 KB | Output is correct |
11 | Correct | 1 ms | 652 KB | Output is correct |
12 | Correct | 1 ms | 656 KB | Output is correct |
13 | Correct | 1 ms | 748 KB | Output is correct |
14 | Correct | 1 ms | 752 KB | Output is correct |
15 | Correct | 1 ms | 776 KB | Output is correct |
16 | Correct | 1 ms | 780 KB | Output is correct |
17 | Correct | 1 ms | 784 KB | Output is correct |
18 | Correct | 1 ms | 788 KB | Output is correct |
19 | Correct | 1 ms | 792 KB | Output is correct |
20 | Correct | 2 ms | 800 KB | Output is correct |
21 | Correct | 2 ms | 800 KB | Output is correct |
22 | Correct | 2 ms | 804 KB | Output is correct |
23 | Correct | 2 ms | 948 KB | Output is correct |
24 | Correct | 2 ms | 948 KB | Output is correct |
25 | Correct | 2 ms | 1000 KB | Output is correct |
26 | Correct | 2 ms | 1040 KB | Output is correct |
27 | Correct | 1 ms | 1040 KB | Output is correct |
28 | Correct | 1 ms | 1040 KB | Output is correct |
29 | Correct | 1 ms | 1040 KB | Output is correct |
30 | Correct | 2 ms | 1076 KB | Output is correct |
31 | Correct | 2 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 | 2 ms | 1240 KB | Output is correct |
35 | Correct | 25 ms | 3184 KB | Output is correct |
36 | Correct | 34 ms | 6452 KB | Output is correct |
37 | Correct | 45 ms | 8644 KB | Output is correct |
38 | Correct | 54 ms | 11156 KB | Output is correct |
39 | Correct | 87 ms | 17548 KB | Output is correct |
40 | Correct | 3 ms | 17548 KB | Output is correct |
41 | Correct | 5 ms | 17548 KB | Output is correct |
42 | Correct | 7 ms | 17548 KB | Output is correct |
43 | Correct | 39 ms | 17548 KB | Output is correct |
44 | Correct | 96 ms | 21072 KB | Output is correct |
45 | Correct | 17 ms | 21072 KB | Output is correct |
46 | Correct | 56 ms | 21072 KB | Output is correct |
47 | Correct | 88 ms | 25000 KB | Output is correct |
48 | Correct | 71 ms | 27316 KB | Output is correct |
49 | Correct | 75 ms | 30928 KB | Output is correct |
50 | Correct | 74 ms | 32504 KB | Output is correct |