# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47045 | 2018-04-27T03:36:31 Z | wzy | K개의 묶음 (IZhO14_blocks) | C++11 | 455 ms | 122864 KB |
#include <bits/stdc++.h> using namespace std; int n , k , dp[100005][105] , v[100005] , opt[100005][105] , pointer[105]; stack< pair<int,int> > s[105]; int main(){ scanf("%d%d" , &n , &k); for(int i = 1 ; i<=n ;i ++) scanf("%d" , &v[i]); for(int i = 0 ; i <= n; i ++) for(int j = 0 ; j <= k ; j++) opt[i][j] = 1000000009 , pointer[j] = 0 , dp[i][j] = 0; for(int j = 1 ; j <= k ; j++) for(int i = j ; i <= n; i++){ if(j == 1){ dp[i][j] = max(dp[i-1][j] , v[i]); } else{ int currminimal = dp[i-1][j-1]; while(s[j].size() && s[j].top().second <= v[i]){ currminimal = min(currminimal , s[j].top().first); s[j].pop(); pointer[j]--; } dp[i][j] = min(currminimal + v[i] , opt[pointer[j]][j]); s[j].push(pair<int,int>(currminimal, v[i])); opt[pointer[j] + 1][j] = min(opt[pointer[j]][j] , currminimal + v[i]); pointer[j]++; } } printf("%d\n" , dp[n][k]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 624 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 624 KB | Output is correct |
5 | Correct | 2 ms | 716 KB | Output is correct |
6 | Correct | 2 ms | 716 KB | Output is correct |
7 | Correct | 2 ms | 828 KB | Output is correct |
8 | Correct | 2 ms | 828 KB | Output is correct |
9 | Correct | 2 ms | 828 KB | Output is correct |
10 | Correct | 2 ms | 828 KB | Output is correct |
11 | Correct | 2 ms | 828 KB | Output is correct |
12 | Correct | 2 ms | 916 KB | Output is correct |
13 | Correct | 2 ms | 1020 KB | Output is correct |
14 | Correct | 2 ms | 1020 KB | Output is correct |
15 | Correct | 2 ms | 1020 KB | Output is correct |
16 | Correct | 2 ms | 1020 KB | Output is correct |
17 | Correct | 2 ms | 1020 KB | Output is correct |
18 | Correct | 2 ms | 1020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1020 KB | Output is correct |
2 | Correct | 2 ms | 1020 KB | Output is correct |
3 | Correct | 2 ms | 1020 KB | Output is correct |
4 | Correct | 2 ms | 1020 KB | Output is correct |
5 | Correct | 2 ms | 1020 KB | Output is correct |
6 | Correct | 2 ms | 1020 KB | Output is correct |
7 | Correct | 2 ms | 1020 KB | Output is correct |
8 | Correct | 2 ms | 1020 KB | Output is correct |
9 | Correct | 2 ms | 1020 KB | Output is correct |
10 | Correct | 2 ms | 1020 KB | Output is correct |
11 | Correct | 2 ms | 1020 KB | Output is correct |
12 | Correct | 2 ms | 1020 KB | Output is correct |
13 | Correct | 2 ms | 1020 KB | Output is correct |
14 | Correct | 2 ms | 1020 KB | Output is correct |
15 | Correct | 2 ms | 1020 KB | Output is correct |
16 | Correct | 2 ms | 1020 KB | Output is correct |
17 | Correct | 2 ms | 1020 KB | Output is correct |
18 | Correct | 2 ms | 1020 KB | Output is correct |
19 | Correct | 2 ms | 1020 KB | Output is correct |
20 | Correct | 2 ms | 1020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1020 KB | Output is correct |
2 | Correct | 2 ms | 1020 KB | Output is correct |
3 | Correct | 2 ms | 1020 KB | Output is correct |
4 | Correct | 2 ms | 1020 KB | Output is correct |
5 | Correct | 2 ms | 1020 KB | Output is correct |
6 | Correct | 2 ms | 1020 KB | Output is correct |
7 | Correct | 2 ms | 1040 KB | Output is correct |
8 | Correct | 2 ms | 1040 KB | Output is correct |
9 | Correct | 2 ms | 1040 KB | Output is correct |
10 | Correct | 2 ms | 1040 KB | Output is correct |
11 | Correct | 2 ms | 1040 KB | Output is correct |
12 | Correct | 2 ms | 1040 KB | Output is correct |
13 | Correct | 2 ms | 1064 KB | Output is correct |
14 | Correct | 2 ms | 1068 KB | Output is correct |
15 | Correct | 2 ms | 1076 KB | Output is correct |
16 | Correct | 2 ms | 1076 KB | Output is correct |
17 | Correct | 2 ms | 1076 KB | Output is correct |
18 | Correct | 2 ms | 1088 KB | Output is correct |
19 | Correct | 2 ms | 1092 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 9288 KB | Output is correct |
2 | Correct | 31 ms | 38032 KB | Output is correct |
3 | Correct | 52 ms | 38388 KB | Output is correct |
4 | Correct | 121 ms | 38800 KB | Output is correct |
5 | Correct | 455 ms | 85320 KB | Output is correct |
6 | Correct | 73 ms | 86012 KB | Output is correct |
7 | Correct | 211 ms | 86712 KB | Output is correct |
8 | Correct | 2 ms | 86712 KB | Output is correct |
9 | Correct | 2 ms | 86712 KB | Output is correct |
10 | Correct | 2 ms | 86712 KB | Output is correct |
11 | Correct | 3 ms | 86712 KB | Output is correct |
12 | Correct | 3 ms | 86712 KB | Output is correct |
13 | Correct | 3 ms | 86712 KB | Output is correct |
14 | Correct | 48 ms | 86712 KB | Output is correct |
15 | Correct | 9 ms | 86712 KB | Output is correct |
16 | Correct | 14 ms | 86712 KB | Output is correct |
17 | Correct | 32 ms | 86712 KB | Output is correct |
18 | Correct | 44 ms | 86712 KB | Output is correct |
19 | Correct | 128 ms | 86712 KB | Output is correct |
20 | Correct | 389 ms | 88408 KB | Output is correct |
21 | Correct | 74 ms | 89204 KB | Output is correct |
22 | Correct | 219 ms | 90036 KB | Output is correct |
23 | Correct | 73 ms | 90596 KB | Output is correct |
24 | Correct | 118 ms | 91280 KB | Output is correct |
25 | Correct | 383 ms | 92080 KB | Output is correct |
26 | Correct | 7 ms | 92080 KB | Output is correct |
27 | Correct | 3 ms | 92080 KB | Output is correct |
28 | Correct | 39 ms | 92080 KB | Output is correct |
29 | Correct | 9 ms | 92080 KB | Output is correct |
30 | Correct | 15 ms | 92080 KB | Output is correct |
31 | Correct | 31 ms | 92080 KB | Output is correct |
32 | Correct | 39 ms | 92080 KB | Output is correct |
33 | Correct | 127 ms | 92080 KB | Output is correct |
34 | Correct | 429 ms | 122864 KB | Output is correct |
35 | Correct | 76 ms | 122864 KB | Output is correct |
36 | Correct | 250 ms | 122864 KB | Output is correct |
37 | Correct | 23 ms | 122864 KB | Output is correct |
38 | Correct | 30 ms | 122864 KB | Output is correct |
39 | Correct | 3 ms | 122864 KB | Output is correct |
40 | Correct | 2 ms | 122864 KB | Output is correct |
41 | Correct | 2 ms | 122864 KB | Output is correct |
42 | Correct | 2 ms | 122864 KB | Output is correct |