답안 #393390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393390 2021-04-23T11:02:46 Z asbsfds K개의 묶음 (IZhO14_blocks) C++14
100 / 100
218 ms 87888 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< pair<int, int>, int> > s;
		for (int j = 1; j <= n; j++) {
			int mini = dp[i - 1][j - 1];
			while (!s.empty() && s.top().first.first <= niz[j]) {
				mini = min(mini, s.top().first.second);
				s.pop();
			}
			
			pair<pair<int, int>, int> tren = make_pair(make_pair(niz[j], mini), niz[j] + mini);
			if (!s.empty()) {
				tren.second = min(tren.second, s.top().second);
			}
			
			s.push(tren);
			//printf("inserting: %d %d %d\n", niz[j], mini, tren.second);
			
			//printf("ave: ");
			//for (auto iter : qs) printf("%d ", iter); printf("\n");
			dp[i][j] = tren.second;
		}
	}
	
	printf("%d\n", dp[k][n]);
	return 0;
}

Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
blocks.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 86340 KB Output is correct
2 Correct 37 ms 86388 KB Output is correct
3 Correct 36 ms 86384 KB Output is correct
4 Correct 37 ms 86356 KB Output is correct
5 Correct 37 ms 86388 KB Output is correct
6 Correct 36 ms 86384 KB Output is correct
7 Correct 36 ms 86348 KB Output is correct
8 Correct 38 ms 86348 KB Output is correct
9 Correct 38 ms 86328 KB Output is correct
10 Correct 37 ms 86348 KB Output is correct
11 Correct 37 ms 86400 KB Output is correct
12 Correct 37 ms 86312 KB Output is correct
13 Correct 38 ms 86340 KB Output is correct
14 Correct 38 ms 86356 KB Output is correct
15 Correct 38 ms 86320 KB Output is correct
16 Correct 36 ms 86340 KB Output is correct
17 Correct 36 ms 86332 KB Output is correct
18 Correct 37 ms 86348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 86332 KB Output is correct
2 Correct 36 ms 86360 KB Output is correct
3 Correct 36 ms 86312 KB Output is correct
4 Correct 41 ms 86364 KB Output is correct
5 Correct 38 ms 86340 KB Output is correct
6 Correct 41 ms 86300 KB Output is correct
7 Correct 37 ms 86340 KB Output is correct
8 Correct 38 ms 86332 KB Output is correct
9 Correct 44 ms 86340 KB Output is correct
10 Correct 38 ms 86380 KB Output is correct
11 Correct 42 ms 86348 KB Output is correct
12 Correct 38 ms 86340 KB Output is correct
13 Correct 37 ms 86372 KB Output is correct
14 Correct 39 ms 86340 KB Output is correct
15 Correct 37 ms 86296 KB Output is correct
16 Correct 39 ms 86388 KB Output is correct
17 Correct 38 ms 86340 KB Output is correct
18 Correct 37 ms 86320 KB Output is correct
19 Correct 38 ms 86296 KB Output is correct
20 Correct 37 ms 86340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 86340 KB Output is correct
2 Correct 37 ms 86388 KB Output is correct
3 Correct 36 ms 86384 KB Output is correct
4 Correct 37 ms 86356 KB Output is correct
5 Correct 37 ms 86388 KB Output is correct
6 Correct 36 ms 86384 KB Output is correct
7 Correct 36 ms 86348 KB Output is correct
8 Correct 38 ms 86348 KB Output is correct
9 Correct 38 ms 86328 KB Output is correct
10 Correct 37 ms 86348 KB Output is correct
11 Correct 37 ms 86400 KB Output is correct
12 Correct 37 ms 86312 KB Output is correct
13 Correct 38 ms 86340 KB Output is correct
14 Correct 38 ms 86356 KB Output is correct
15 Correct 38 ms 86320 KB Output is correct
16 Correct 36 ms 86340 KB Output is correct
17 Correct 36 ms 86332 KB Output is correct
18 Correct 37 ms 86348 KB Output is correct
19 Correct 37 ms 86332 KB Output is correct
20 Correct 36 ms 86360 KB Output is correct
21 Correct 36 ms 86312 KB Output is correct
22 Correct 41 ms 86364 KB Output is correct
23 Correct 38 ms 86340 KB Output is correct
24 Correct 41 ms 86300 KB Output is correct
25 Correct 37 ms 86340 KB Output is correct
26 Correct 38 ms 86332 KB Output is correct
27 Correct 44 ms 86340 KB Output is correct
28 Correct 38 ms 86380 KB Output is correct
29 Correct 42 ms 86348 KB Output is correct
30 Correct 38 ms 86340 KB Output is correct
31 Correct 37 ms 86372 KB Output is correct
32 Correct 39 ms 86340 KB Output is correct
33 Correct 37 ms 86296 KB Output is correct
34 Correct 39 ms 86388 KB Output is correct
35 Correct 38 ms 86340 KB Output is correct
36 Correct 37 ms 86320 KB Output is correct
37 Correct 38 ms 86296 KB Output is correct
38 Correct 37 ms 86340 KB Output is correct
39 Correct 37 ms 86340 KB Output is correct
40 Correct 35 ms 86312 KB Output is correct
41 Correct 36 ms 86324 KB Output is correct
42 Correct 38 ms 86312 KB Output is correct
43 Correct 45 ms 86360 KB Output is correct
44 Correct 44 ms 86324 KB Output is correct
45 Correct 37 ms 86332 KB Output is correct
46 Correct 39 ms 86368 KB Output is correct
47 Correct 36 ms 86292 KB Output is correct
48 Correct 37 ms 86340 KB Output is correct
49 Correct 39 ms 86328 KB Output is correct
50 Correct 37 ms 86304 KB Output is correct
51 Correct 38 ms 86376 KB Output is correct
52 Correct 37 ms 86336 KB Output is correct
53 Correct 37 ms 86320 KB Output is correct
54 Correct 38 ms 86320 KB Output is correct
55 Correct 37 ms 86360 KB Output is correct
56 Correct 38 ms 86348 KB Output is correct
57 Correct 37 ms 86340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 86340 KB Output is correct
2 Correct 37 ms 86388 KB Output is correct
3 Correct 36 ms 86384 KB Output is correct
4 Correct 37 ms 86356 KB Output is correct
5 Correct 37 ms 86388 KB Output is correct
6 Correct 36 ms 86384 KB Output is correct
7 Correct 36 ms 86348 KB Output is correct
8 Correct 38 ms 86348 KB Output is correct
9 Correct 38 ms 86328 KB Output is correct
10 Correct 37 ms 86348 KB Output is correct
11 Correct 37 ms 86400 KB Output is correct
12 Correct 37 ms 86312 KB Output is correct
13 Correct 38 ms 86340 KB Output is correct
14 Correct 38 ms 86356 KB Output is correct
15 Correct 38 ms 86320 KB Output is correct
16 Correct 36 ms 86340 KB Output is correct
17 Correct 36 ms 86332 KB Output is correct
18 Correct 37 ms 86348 KB Output is correct
19 Correct 37 ms 86332 KB Output is correct
20 Correct 36 ms 86360 KB Output is correct
21 Correct 36 ms 86312 KB Output is correct
22 Correct 41 ms 86364 KB Output is correct
23 Correct 38 ms 86340 KB Output is correct
24 Correct 41 ms 86300 KB Output is correct
25 Correct 37 ms 86340 KB Output is correct
26 Correct 38 ms 86332 KB Output is correct
27 Correct 44 ms 86340 KB Output is correct
28 Correct 38 ms 86380 KB Output is correct
29 Correct 42 ms 86348 KB Output is correct
30 Correct 38 ms 86340 KB Output is correct
31 Correct 37 ms 86372 KB Output is correct
32 Correct 39 ms 86340 KB Output is correct
33 Correct 37 ms 86296 KB Output is correct
34 Correct 39 ms 86388 KB Output is correct
35 Correct 38 ms 86340 KB Output is correct
36 Correct 37 ms 86320 KB Output is correct
37 Correct 38 ms 86296 KB Output is correct
38 Correct 37 ms 86340 KB Output is correct
39 Correct 37 ms 86340 KB Output is correct
40 Correct 35 ms 86312 KB Output is correct
41 Correct 36 ms 86324 KB Output is correct
42 Correct 38 ms 86312 KB Output is correct
43 Correct 45 ms 86360 KB Output is correct
44 Correct 44 ms 86324 KB Output is correct
45 Correct 37 ms 86332 KB Output is correct
46 Correct 39 ms 86368 KB Output is correct
47 Correct 36 ms 86292 KB Output is correct
48 Correct 37 ms 86340 KB Output is correct
49 Correct 39 ms 86328 KB Output is correct
50 Correct 37 ms 86304 KB Output is correct
51 Correct 38 ms 86376 KB Output is correct
52 Correct 37 ms 86336 KB Output is correct
53 Correct 37 ms 86320 KB Output is correct
54 Correct 38 ms 86320 KB Output is correct
55 Correct 37 ms 86360 KB Output is correct
56 Correct 38 ms 86348 KB Output is correct
57 Correct 37 ms 86340 KB Output is correct
58 Correct 40 ms 86412 KB Output is correct
59 Correct 43 ms 86492 KB Output is correct
60 Correct 47 ms 86524 KB Output is correct
61 Correct 83 ms 86564 KB Output is correct
62 Correct 167 ms 86732 KB Output is correct
63 Correct 53 ms 86688 KB Output is correct
64 Correct 100 ms 86700 KB Output is correct
65 Correct 37 ms 86356 KB Output is correct
66 Correct 37 ms 86396 KB Output is correct
67 Correct 37 ms 86316 KB Output is correct
68 Correct 41 ms 86308 KB Output is correct
69 Correct 37 ms 86340 KB Output is correct
70 Correct 38 ms 86404 KB Output is correct
71 Correct 53 ms 86340 KB Output is correct
72 Correct 40 ms 86368 KB Output is correct
73 Correct 43 ms 86472 KB Output is correct
74 Correct 43 ms 86468 KB Output is correct
75 Correct 46 ms 86468 KB Output is correct
76 Correct 91 ms 86468 KB Output is correct
77 Correct 203 ms 86844 KB Output is correct
78 Correct 55 ms 86744 KB Output is correct
79 Correct 115 ms 86724 KB Output is correct
80 Correct 50 ms 86684 KB Output is correct
81 Correct 63 ms 86784 KB Output is correct
82 Correct 218 ms 86852 KB Output is correct
83 Correct 42 ms 86336 KB Output is correct
84 Correct 37 ms 86340 KB Output is correct
85 Correct 50 ms 86468 KB Output is correct
86 Correct 38 ms 86464 KB Output is correct
87 Correct 42 ms 86456 KB Output is correct
88 Correct 43 ms 86752 KB Output is correct
89 Correct 47 ms 86748 KB Output is correct
90 Correct 88 ms 86860 KB Output is correct
91 Correct 191 ms 87212 KB Output is correct
92 Correct 57 ms 87868 KB Output is correct
93 Correct 113 ms 87888 KB Output is correct
94 Correct 39 ms 86404 KB Output is correct
95 Correct 53 ms 86484 KB Output is correct
96 Correct 37 ms 86376 KB Output is correct
97 Correct 38 ms 86372 KB Output is correct
98 Correct 37 ms 86344 KB Output is correct
99 Correct 37 ms 86340 KB Output is correct