# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168067 | 2019-12-11T08:54:18 Z | GioChkhaidze | K개의 묶음 (IZhO14_blocks) | C++14 | 246 ms | 42872 KB |
#include <bits/stdc++.h> #define F first #define S second using namespace std; const int N=1e5+5,K=105; int n,k; int a[N],dp[N][K]; stack < pair < int , int > > st ; main ( ){ scanf("%d%d",&n,&k); for (int i=1; i<=n; i++) { scanf("%d",&a[i]); dp[i][1]=max(dp[i-1][1],a[i]); } for (int j=2; j<=k; j++) { while (st.size()) st.pop(); for (int i=j; i<=n; i++) { int h=a[i],up=dp[i-1][j-1]; while (st.size() && st.top().F<=h) { up=min(up,st.top().S); st.pop(); } if (!st.size() || st.top().F+st.top().S>=up+h) st.push({h,up}); dp[i][j]=st.top().F+st.top().S; } } printf("%d\n",dp[n][k]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 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 | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 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 | 376 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 | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 380 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 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 | 376 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 | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4600 KB | Output is correct |
2 | Correct | 21 ms | 19192 KB | Output is correct |
3 | Correct | 25 ms | 19064 KB | Output is correct |
4 | Correct | 67 ms | 19116 KB | Output is correct |
5 | Correct | 188 ms | 42588 KB | Output is correct |
6 | Correct | 50 ms | 42488 KB | Output is correct |
7 | Correct | 111 ms | 42616 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 424 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 2 ms | 764 KB | Output is correct |
13 | Correct | 3 ms | 760 KB | Output is correct |
14 | Correct | 22 ms | 4644 KB | Output is correct |
15 | Correct | 7 ms | 4600 KB | Output is correct |
16 | Correct | 11 ms | 4700 KB | Output is correct |
17 | Correct | 22 ms | 19064 KB | Output is correct |
18 | Correct | 27 ms | 19064 KB | Output is correct |
19 | Correct | 75 ms | 19036 KB | Output is correct |
20 | Correct | 228 ms | 42488 KB | Output is correct |
21 | Correct | 54 ms | 42488 KB | Output is correct |
22 | Correct | 131 ms | 42492 KB | Output is correct |
23 | Correct | 47 ms | 42488 KB | Output is correct |
24 | Correct | 62 ms | 42444 KB | Output is correct |
25 | Correct | 205 ms | 42488 KB | Output is correct |
26 | Correct | 2 ms | 760 KB | Output is correct |
27 | Correct | 2 ms | 760 KB | Output is correct |
28 | Correct | 24 ms | 4600 KB | Output is correct |
29 | Correct | 7 ms | 4600 KB | Output is correct |
30 | Correct | 12 ms | 4600 KB | Output is correct |
31 | Correct | 24 ms | 19064 KB | Output is correct |
32 | Correct | 27 ms | 19192 KB | Output is correct |
33 | Correct | 86 ms | 19192 KB | Output is correct |
34 | Correct | 246 ms | 42744 KB | Output is correct |
35 | Correct | 51 ms | 42744 KB | Output is correct |
36 | Correct | 137 ms | 42872 KB | Output is correct |
37 | Correct | 6 ms | 4600 KB | Output is correct |
38 | Correct | 18 ms | 4600 KB | Output is correct |
39 | Correct | 16 ms | 760 KB | Output is correct |
40 | Correct | 2 ms | 760 KB | Output is correct |
41 | Correct | 2 ms | 376 KB | Output is correct |
42 | Correct | 2 ms | 376 KB | Output is correct |