답안 #870018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870018 2023-11-06T16:08:06 Z truongdoan2012 K개의 묶음 (IZhO14_blocks) C++17
53 / 100
1000 ms 80988 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

using i64 = long long;
const int N = 1e5 + 10;
i64 dp[N][101]; // min val khi chia i phan tu vao j nhom
i64 a[N], pm[N];

void solve() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pm[i] = max(pm[i - 1], a[i]);
  }
  memset(dp, 127, sizeof dp);
  for (int i = 1; i <= n; i++) {
    dp[i][1] = pm[i];
  }
  for (int j = 2; j <= k; j++) {
    for (int i = j; i <= n; i++) {
      i64 t = a[i];
      for (int p = i; p >= 1; p--) {
        t = max(t, a[p]);
        dp[i][j] = min(dp[i][j], dp[p - 1][j - 1] + t);
      }
    }
  }
  cout << dp[n][k];
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int TC = 1;
  // cin >> TC;
  while (TC--) {
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 80732 KB Output is correct
2 Correct 10 ms 80732 KB Output is correct
3 Correct 9 ms 80732 KB Output is correct
4 Correct 10 ms 80752 KB Output is correct
5 Correct 10 ms 80732 KB Output is correct
6 Correct 10 ms 80892 KB Output is correct
7 Correct 9 ms 80732 KB Output is correct
8 Correct 10 ms 80732 KB Output is correct
9 Correct 10 ms 80732 KB Output is correct
10 Correct 9 ms 80732 KB Output is correct
11 Correct 9 ms 80732 KB Output is correct
12 Correct 10 ms 80844 KB Output is correct
13 Correct 10 ms 80844 KB Output is correct
14 Correct 10 ms 80668 KB Output is correct
15 Correct 9 ms 80732 KB Output is correct
16 Correct 10 ms 80880 KB Output is correct
17 Correct 10 ms 80732 KB Output is correct
18 Correct 10 ms 80732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 80728 KB Output is correct
2 Correct 10 ms 80688 KB Output is correct
3 Correct 11 ms 80732 KB Output is correct
4 Correct 9 ms 80732 KB Output is correct
5 Correct 10 ms 80732 KB Output is correct
6 Correct 10 ms 80732 KB Output is correct
7 Correct 10 ms 80732 KB Output is correct
8 Correct 10 ms 80732 KB Output is correct
9 Correct 10 ms 80728 KB Output is correct
10 Correct 10 ms 80732 KB Output is correct
11 Correct 10 ms 80732 KB Output is correct
12 Correct 9 ms 80732 KB Output is correct
13 Correct 11 ms 80688 KB Output is correct
14 Correct 10 ms 80732 KB Output is correct
15 Correct 10 ms 80732 KB Output is correct
16 Correct 9 ms 80740 KB Output is correct
17 Correct 10 ms 80728 KB Output is correct
18 Correct 11 ms 80732 KB Output is correct
19 Correct 10 ms 80732 KB Output is correct
20 Correct 10 ms 80732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 80732 KB Output is correct
2 Correct 10 ms 80732 KB Output is correct
3 Correct 9 ms 80732 KB Output is correct
4 Correct 10 ms 80752 KB Output is correct
5 Correct 10 ms 80732 KB Output is correct
6 Correct 10 ms 80892 KB Output is correct
7 Correct 9 ms 80732 KB Output is correct
8 Correct 10 ms 80732 KB Output is correct
9 Correct 10 ms 80732 KB Output is correct
10 Correct 9 ms 80732 KB Output is correct
11 Correct 9 ms 80732 KB Output is correct
12 Correct 10 ms 80844 KB Output is correct
13 Correct 10 ms 80844 KB Output is correct
14 Correct 10 ms 80668 KB Output is correct
15 Correct 9 ms 80732 KB Output is correct
16 Correct 10 ms 80880 KB Output is correct
17 Correct 10 ms 80732 KB Output is correct
18 Correct 10 ms 80732 KB Output is correct
19 Correct 10 ms 80728 KB Output is correct
20 Correct 10 ms 80688 KB Output is correct
21 Correct 11 ms 80732 KB Output is correct
22 Correct 9 ms 80732 KB Output is correct
23 Correct 10 ms 80732 KB Output is correct
24 Correct 10 ms 80732 KB Output is correct
25 Correct 10 ms 80732 KB Output is correct
26 Correct 10 ms 80732 KB Output is correct
27 Correct 10 ms 80728 KB Output is correct
28 Correct 10 ms 80732 KB Output is correct
29 Correct 10 ms 80732 KB Output is correct
30 Correct 9 ms 80732 KB Output is correct
31 Correct 11 ms 80688 KB Output is correct
32 Correct 10 ms 80732 KB Output is correct
33 Correct 10 ms 80732 KB Output is correct
34 Correct 9 ms 80740 KB Output is correct
35 Correct 10 ms 80728 KB Output is correct
36 Correct 11 ms 80732 KB Output is correct
37 Correct 10 ms 80732 KB Output is correct
38 Correct 10 ms 80732 KB Output is correct
39 Correct 10 ms 80984 KB Output is correct
40 Correct 9 ms 80732 KB Output is correct
41 Correct 11 ms 80732 KB Output is correct
42 Correct 11 ms 80732 KB Output is correct
43 Correct 9 ms 80732 KB Output is correct
44 Correct 9 ms 80732 KB Output is correct
45 Correct 10 ms 80676 KB Output is correct
46 Correct 10 ms 80732 KB Output is correct
47 Correct 10 ms 80716 KB Output is correct
48 Correct 9 ms 80732 KB Output is correct
49 Correct 10 ms 80732 KB Output is correct
50 Correct 10 ms 80732 KB Output is correct
51 Correct 10 ms 80728 KB Output is correct
52 Correct 10 ms 80732 KB Output is correct
53 Correct 12 ms 80856 KB Output is correct
54 Correct 10 ms 80728 KB Output is correct
55 Correct 10 ms 80732 KB Output is correct
56 Correct 10 ms 80732 KB Output is correct
57 Correct 10 ms 80728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 80732 KB Output is correct
2 Correct 10 ms 80732 KB Output is correct
3 Correct 9 ms 80732 KB Output is correct
4 Correct 10 ms 80752 KB Output is correct
5 Correct 10 ms 80732 KB Output is correct
6 Correct 10 ms 80892 KB Output is correct
7 Correct 9 ms 80732 KB Output is correct
8 Correct 10 ms 80732 KB Output is correct
9 Correct 10 ms 80732 KB Output is correct
10 Correct 9 ms 80732 KB Output is correct
11 Correct 9 ms 80732 KB Output is correct
12 Correct 10 ms 80844 KB Output is correct
13 Correct 10 ms 80844 KB Output is correct
14 Correct 10 ms 80668 KB Output is correct
15 Correct 9 ms 80732 KB Output is correct
16 Correct 10 ms 80880 KB Output is correct
17 Correct 10 ms 80732 KB Output is correct
18 Correct 10 ms 80732 KB Output is correct
19 Correct 10 ms 80728 KB Output is correct
20 Correct 10 ms 80688 KB Output is correct
21 Correct 11 ms 80732 KB Output is correct
22 Correct 9 ms 80732 KB Output is correct
23 Correct 10 ms 80732 KB Output is correct
24 Correct 10 ms 80732 KB Output is correct
25 Correct 10 ms 80732 KB Output is correct
26 Correct 10 ms 80732 KB Output is correct
27 Correct 10 ms 80728 KB Output is correct
28 Correct 10 ms 80732 KB Output is correct
29 Correct 10 ms 80732 KB Output is correct
30 Correct 9 ms 80732 KB Output is correct
31 Correct 11 ms 80688 KB Output is correct
32 Correct 10 ms 80732 KB Output is correct
33 Correct 10 ms 80732 KB Output is correct
34 Correct 9 ms 80740 KB Output is correct
35 Correct 10 ms 80728 KB Output is correct
36 Correct 11 ms 80732 KB Output is correct
37 Correct 10 ms 80732 KB Output is correct
38 Correct 10 ms 80732 KB Output is correct
39 Correct 10 ms 80984 KB Output is correct
40 Correct 9 ms 80732 KB Output is correct
41 Correct 11 ms 80732 KB Output is correct
42 Correct 11 ms 80732 KB Output is correct
43 Correct 9 ms 80732 KB Output is correct
44 Correct 9 ms 80732 KB Output is correct
45 Correct 10 ms 80676 KB Output is correct
46 Correct 10 ms 80732 KB Output is correct
47 Correct 10 ms 80716 KB Output is correct
48 Correct 9 ms 80732 KB Output is correct
49 Correct 10 ms 80732 KB Output is correct
50 Correct 10 ms 80732 KB Output is correct
51 Correct 10 ms 80728 KB Output is correct
52 Correct 10 ms 80732 KB Output is correct
53 Correct 12 ms 80856 KB Output is correct
54 Correct 10 ms 80728 KB Output is correct
55 Correct 10 ms 80732 KB Output is correct
56 Correct 10 ms 80732 KB Output is correct
57 Correct 10 ms 80728 KB Output is correct
58 Execution timed out 1035 ms 80988 KB Time limit exceeded
59 Halted 0 ms 0 KB -