# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
393386 | 2021-04-23T10:55:24 Z | asbsfds | K개의 묶음 (IZhO14_blocks) | C++14 | 1000 ms | 89448 KB |
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 2e5+10; const int maxk = 110; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int n, k; int niz[maxn]; int dp[maxk][maxn]; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) scanf("%d", niz+i); memset(dp, inf, sizeof dp); dp[0][0] = 0; for (int i = 1; i <= k; i++) { stack< pair<int, int> > s; multiset< int > qs; for (int j = 1; j <= n; j++) { int mini = dp[i - 1][j - 1]; while (!s.empty() && s.top().first <= niz[j]) { mini = min(mini, s.top().second); qs.erase(qs.find(s.top().second + s.top().first)); s.pop(); } s.push(make_pair(niz[j], mini)); //printf("inserting: %d %d\n", niz[j], mini); qs.insert(mini + niz[j]); //printf("ave: "); //for (auto iter : qs) printf("%d ", iter); printf("\n"); dp[i][j] = *qs.begin(); } } printf("%d\n", dp[k][n]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 86348 KB | Output is correct |
2 | Correct | 45 ms | 86380 KB | Output is correct |
3 | Correct | 40 ms | 86344 KB | Output is correct |
4 | Correct | 39 ms | 86308 KB | Output is correct |
5 | Correct | 38 ms | 86456 KB | Output is correct |
6 | Correct | 40 ms | 86336 KB | Output is correct |
7 | Correct | 38 ms | 86336 KB | Output is correct |
8 | Correct | 39 ms | 86340 KB | Output is correct |
9 | Correct | 38 ms | 86292 KB | Output is correct |
10 | Correct | 39 ms | 86304 KB | Output is correct |
11 | Correct | 39 ms | 86340 KB | Output is correct |
12 | Correct | 43 ms | 86436 KB | Output is correct |
13 | Correct | 42 ms | 86312 KB | Output is correct |
14 | Correct | 39 ms | 86308 KB | Output is correct |
15 | Correct | 38 ms | 86312 KB | Output is correct |
16 | Correct | 39 ms | 86288 KB | Output is correct |
17 | Correct | 39 ms | 86364 KB | Output is correct |
18 | Correct | 39 ms | 86340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 86348 KB | Output is correct |
2 | Correct | 40 ms | 86336 KB | Output is correct |
3 | Correct | 39 ms | 86392 KB | Output is correct |
4 | Correct | 39 ms | 86336 KB | Output is correct |
5 | Correct | 39 ms | 86372 KB | Output is correct |
6 | Correct | 39 ms | 86312 KB | Output is correct |
7 | Correct | 39 ms | 86344 KB | Output is correct |
8 | Correct | 38 ms | 86348 KB | Output is correct |
9 | Correct | 38 ms | 86376 KB | Output is correct |
10 | Correct | 38 ms | 86384 KB | Output is correct |
11 | Correct | 40 ms | 86316 KB | Output is correct |
12 | Correct | 39 ms | 86344 KB | Output is correct |
13 | Correct | 39 ms | 86364 KB | Output is correct |
14 | Correct | 39 ms | 86300 KB | Output is correct |
15 | Correct | 39 ms | 86308 KB | Output is correct |
16 | Correct | 40 ms | 86364 KB | Output is correct |
17 | Correct | 44 ms | 86312 KB | Output is correct |
18 | Correct | 44 ms | 86304 KB | Output is correct |
19 | Correct | 40 ms | 86388 KB | Output is correct |
20 | Correct | 39 ms | 86300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 86348 KB | Output is correct |
2 | Correct | 45 ms | 86380 KB | Output is correct |
3 | Correct | 40 ms | 86344 KB | Output is correct |
4 | Correct | 39 ms | 86308 KB | Output is correct |
5 | Correct | 38 ms | 86456 KB | Output is correct |
6 | Correct | 40 ms | 86336 KB | Output is correct |
7 | Correct | 38 ms | 86336 KB | Output is correct |
8 | Correct | 39 ms | 86340 KB | Output is correct |
9 | Correct | 38 ms | 86292 KB | Output is correct |
10 | Correct | 39 ms | 86304 KB | Output is correct |
11 | Correct | 39 ms | 86340 KB | Output is correct |
12 | Correct | 43 ms | 86436 KB | Output is correct |
13 | Correct | 42 ms | 86312 KB | Output is correct |
14 | Correct | 39 ms | 86308 KB | Output is correct |
15 | Correct | 38 ms | 86312 KB | Output is correct |
16 | Correct | 39 ms | 86288 KB | Output is correct |
17 | Correct | 39 ms | 86364 KB | Output is correct |
18 | Correct | 39 ms | 86340 KB | Output is correct |
19 | Correct | 39 ms | 86348 KB | Output is correct |
20 | Correct | 40 ms | 86336 KB | Output is correct |
21 | Correct | 39 ms | 86392 KB | Output is correct |
22 | Correct | 39 ms | 86336 KB | Output is correct |
23 | Correct | 39 ms | 86372 KB | Output is correct |
24 | Correct | 39 ms | 86312 KB | Output is correct |
25 | Correct | 39 ms | 86344 KB | Output is correct |
26 | Correct | 38 ms | 86348 KB | Output is correct |
27 | Correct | 38 ms | 86376 KB | Output is correct |
28 | Correct | 38 ms | 86384 KB | Output is correct |
29 | Correct | 40 ms | 86316 KB | Output is correct |
30 | Correct | 39 ms | 86344 KB | Output is correct |
31 | Correct | 39 ms | 86364 KB | Output is correct |
32 | Correct | 39 ms | 86300 KB | Output is correct |
33 | Correct | 39 ms | 86308 KB | Output is correct |
34 | Correct | 40 ms | 86364 KB | Output is correct |
35 | Correct | 44 ms | 86312 KB | Output is correct |
36 | Correct | 44 ms | 86304 KB | Output is correct |
37 | Correct | 40 ms | 86388 KB | Output is correct |
38 | Correct | 39 ms | 86300 KB | Output is correct |
39 | Correct | 38 ms | 86360 KB | Output is correct |
40 | Correct | 37 ms | 86328 KB | Output is correct |
41 | Correct | 44 ms | 86352 KB | Output is correct |
42 | Correct | 45 ms | 86372 KB | Output is correct |
43 | Correct | 38 ms | 86340 KB | Output is correct |
44 | Correct | 38 ms | 86272 KB | Output is correct |
45 | Correct | 40 ms | 86388 KB | Output is correct |
46 | Correct | 40 ms | 86372 KB | Output is correct |
47 | Correct | 42 ms | 86392 KB | Output is correct |
48 | Correct | 39 ms | 86344 KB | Output is correct |
49 | Correct | 39 ms | 86304 KB | Output is correct |
50 | Correct | 38 ms | 86320 KB | Output is correct |
51 | Correct | 39 ms | 86380 KB | Output is correct |
52 | Correct | 38 ms | 86340 KB | Output is correct |
53 | Correct | 41 ms | 86340 KB | Output is correct |
54 | Correct | 40 ms | 86432 KB | Output is correct |
55 | Correct | 37 ms | 86304 KB | Output is correct |
56 | Correct | 40 ms | 86372 KB | Output is correct |
57 | Correct | 41 ms | 86328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 86348 KB | Output is correct |
2 | Correct | 45 ms | 86380 KB | Output is correct |
3 | Correct | 40 ms | 86344 KB | Output is correct |
4 | Correct | 39 ms | 86308 KB | Output is correct |
5 | Correct | 38 ms | 86456 KB | Output is correct |
6 | Correct | 40 ms | 86336 KB | Output is correct |
7 | Correct | 38 ms | 86336 KB | Output is correct |
8 | Correct | 39 ms | 86340 KB | Output is correct |
9 | Correct | 38 ms | 86292 KB | Output is correct |
10 | Correct | 39 ms | 86304 KB | Output is correct |
11 | Correct | 39 ms | 86340 KB | Output is correct |
12 | Correct | 43 ms | 86436 KB | Output is correct |
13 | Correct | 42 ms | 86312 KB | Output is correct |
14 | Correct | 39 ms | 86308 KB | Output is correct |
15 | Correct | 38 ms | 86312 KB | Output is correct |
16 | Correct | 39 ms | 86288 KB | Output is correct |
17 | Correct | 39 ms | 86364 KB | Output is correct |
18 | Correct | 39 ms | 86340 KB | Output is correct |
19 | Correct | 39 ms | 86348 KB | Output is correct |
20 | Correct | 40 ms | 86336 KB | Output is correct |
21 | Correct | 39 ms | 86392 KB | Output is correct |
22 | Correct | 39 ms | 86336 KB | Output is correct |
23 | Correct | 39 ms | 86372 KB | Output is correct |
24 | Correct | 39 ms | 86312 KB | Output is correct |
25 | Correct | 39 ms | 86344 KB | Output is correct |
26 | Correct | 38 ms | 86348 KB | Output is correct |
27 | Correct | 38 ms | 86376 KB | Output is correct |
28 | Correct | 38 ms | 86384 KB | Output is correct |
29 | Correct | 40 ms | 86316 KB | Output is correct |
30 | Correct | 39 ms | 86344 KB | Output is correct |
31 | Correct | 39 ms | 86364 KB | Output is correct |
32 | Correct | 39 ms | 86300 KB | Output is correct |
33 | Correct | 39 ms | 86308 KB | Output is correct |
34 | Correct | 40 ms | 86364 KB | Output is correct |
35 | Correct | 44 ms | 86312 KB | Output is correct |
36 | Correct | 44 ms | 86304 KB | Output is correct |
37 | Correct | 40 ms | 86388 KB | Output is correct |
38 | Correct | 39 ms | 86300 KB | Output is correct |
39 | Correct | 38 ms | 86360 KB | Output is correct |
40 | Correct | 37 ms | 86328 KB | Output is correct |
41 | Correct | 44 ms | 86352 KB | Output is correct |
42 | Correct | 45 ms | 86372 KB | Output is correct |
43 | Correct | 38 ms | 86340 KB | Output is correct |
44 | Correct | 38 ms | 86272 KB | Output is correct |
45 | Correct | 40 ms | 86388 KB | Output is correct |
46 | Correct | 40 ms | 86372 KB | Output is correct |
47 | Correct | 42 ms | 86392 KB | Output is correct |
48 | Correct | 39 ms | 86344 KB | Output is correct |
49 | Correct | 39 ms | 86304 KB | Output is correct |
50 | Correct | 38 ms | 86320 KB | Output is correct |
51 | Correct | 39 ms | 86380 KB | Output is correct |
52 | Correct | 38 ms | 86340 KB | Output is correct |
53 | Correct | 41 ms | 86340 KB | Output is correct |
54 | Correct | 40 ms | 86432 KB | Output is correct |
55 | Correct | 37 ms | 86304 KB | Output is correct |
56 | Correct | 40 ms | 86372 KB | Output is correct |
57 | Correct | 41 ms | 86328 KB | Output is correct |
58 | Correct | 49 ms | 86412 KB | Output is correct |
59 | Correct | 47 ms | 86832 KB | Output is correct |
60 | Correct | 58 ms | 86852 KB | Output is correct |
61 | Correct | 198 ms | 86964 KB | Output is correct |
62 | Correct | 478 ms | 87364 KB | Output is correct |
63 | Correct | 64 ms | 87376 KB | Output is correct |
64 | Correct | 247 ms | 87476 KB | Output is correct |
65 | Correct | 39 ms | 86340 KB | Output is correct |
66 | Correct | 40 ms | 86444 KB | Output is correct |
67 | Correct | 39 ms | 86280 KB | Output is correct |
68 | Correct | 39 ms | 86356 KB | Output is correct |
69 | Correct | 46 ms | 86340 KB | Output is correct |
70 | Correct | 46 ms | 86344 KB | Output is correct |
71 | Correct | 122 ms | 86412 KB | Output is correct |
72 | Correct | 41 ms | 86524 KB | Output is correct |
73 | Correct | 62 ms | 86604 KB | Output is correct |
74 | Correct | 47 ms | 86852 KB | Output is correct |
75 | Correct | 68 ms | 86860 KB | Output is correct |
76 | Correct | 336 ms | 86812 KB | Output is correct |
77 | Correct | 929 ms | 87456 KB | Output is correct |
78 | Correct | 78 ms | 87372 KB | Output is correct |
79 | Correct | 441 ms | 87452 KB | Output is correct |
80 | Correct | 58 ms | 87364 KB | Output is correct |
81 | Correct | 161 ms | 87460 KB | Output is correct |
82 | Correct | 931 ms | 87460 KB | Output is correct |
83 | Correct | 40 ms | 86340 KB | Output is correct |
84 | Correct | 38 ms | 86420 KB | Output is correct |
85 | Correct | 143 ms | 86692 KB | Output is correct |
86 | Correct | 42 ms | 86612 KB | Output is correct |
87 | Correct | 66 ms | 86668 KB | Output is correct |
88 | Correct | 49 ms | 87716 KB | Output is correct |
89 | Correct | 82 ms | 87732 KB | Output is correct |
90 | Correct | 449 ms | 87728 KB | Output is correct |
91 | Execution timed out | 1098 ms | 89448 KB | Time limit exceeded |
92 | Halted | 0 ms | 0 KB | - |