# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
167105 | 2019-12-06T02:02:50 Z | dantoh000 | Hacker (BOI15_hac) | C++14 | 104 ms | 13896 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int main(){ int n; scanf("%d",&n); int k = (n+1)/2; int l = (n)/2; //printf("%d",k); int a[n+1],p[n+1]; a[0]= p[0] = 0; for (int i = 1; i <= n; i++) { scanf("%d",&a[i]); p[i] = p[i-1] + a[i]; } vector<int> v; for (int i = 1; i <= n; i++){ if (i >= k){ //printf("%d %d\n",i, p[i]-p[i-k]); v.push_back(p[i]-p[i-k]); } else{ //printf("%d %d-%d+%d=%d\n",i, p[n],p[i+l], p[i],p[n]-p[i+l]+p[i]); v.push_back(p[n]-p[i+l]+p[i]); } } deque<ii> dq; vector<int> w; int ans = 0; for (auto x : v) w.push_back(x); for (auto x : w) v.push_back(x); for (int i = 0; i < 2*n; i++){ while (dq.size() && dq.back().first >= v[i]) dq.pop_back(); if (dq.size() && i >= k && dq.front().second == i-k) dq.pop_front(); dq.push_back(ii(v[i],i)); //printf("deque contains: " ); //for (auto x : dq) printf("(%d %d)",x.first,x.second); //printf("\n"); if (i >= k) ans = max(ans,dq.front().first); } printf("%d",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 400 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 400 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 3 ms | 508 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 504 KB | Output is correct |
26 | Correct | 3 ms | 504 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 3 ms | 504 KB | Output is correct |
31 | Correct | 3 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 19 ms | 2800 KB | Output is correct |
5 | Correct | 40 ms | 5608 KB | Output is correct |
6 | Correct | 51 ms | 6504 KB | Output is correct |
7 | Correct | 63 ms | 9440 KB | Output is correct |
8 | Correct | 104 ms | 12620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 400 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 3 ms | 508 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 504 KB | Output is correct |
26 | Correct | 3 ms | 504 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 3 ms | 504 KB | Output is correct |
31 | Correct | 3 ms | 504 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 3 ms | 504 KB | Output is correct |
35 | Correct | 19 ms | 2800 KB | Output is correct |
36 | Correct | 40 ms | 5608 KB | Output is correct |
37 | Correct | 51 ms | 6504 KB | Output is correct |
38 | Correct | 63 ms | 9440 KB | Output is correct |
39 | Correct | 104 ms | 12620 KB | Output is correct |
40 | Correct | 4 ms | 760 KB | Output is correct |
41 | Correct | 6 ms | 1016 KB | Output is correct |
42 | Correct | 8 ms | 1196 KB | Output is correct |
43 | Correct | 42 ms | 5872 KB | Output is correct |
44 | Correct | 103 ms | 12640 KB | Output is correct |
45 | Correct | 21 ms | 3056 KB | Output is correct |
46 | Correct | 63 ms | 9444 KB | Output is correct |
47 | Correct | 101 ms | 12640 KB | Output is correct |
48 | Correct | 92 ms | 12896 KB | Output is correct |
49 | Correct | 81 ms | 13784 KB | Output is correct |
50 | Correct | 83 ms | 13896 KB | Output is correct |