Submission #336934

# Submission time Handle Problem Language Result Execution time Memory
336934 2020-12-17T11:56:38 Z boykut K blocks (IZhO14_blocks) C++14
53 / 100
1000 ms 4348 KB
#include <map>
#include <vector>
#include <iostream>

using namespace std;

int mx[100][100];

int dp[100][100][100];
int a[100];


int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, K;
  cin >> n >> K;
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      mx[l][r] = a[l];
      for (int i = l + 1; i <= r; i++) {
        mx[l][r] = max(mx[l][r], a[i]);
      }
    }
  }
  
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      for (int _k = 0; _k < 100; _k++) {
        dp[i][j][_k] = 2e9;
      }
    }
  }
  
  int ans = 2e9;
  for (int i = 0; i < n; i++) {
    dp[0][i][0] = mx[0][i];
    if (0 == K - 1 && i == n - 1) {
      ans = min(ans, dp[0][i][0]);
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k <= j - 1; k++) {
        for (int _k = 1; _k < K; _k++) {
          dp[j][i][_k] = min(dp[j][i][_k], dp[k][j - 1][_k - 1] + mx[j][i]);
          if (_k == K - 1 && i == n - 1) {
            ans = min(ans, dp[j][i][_k]);
          }
        }
      }
    }
  }
  
  cout << ans << '\n';
  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 3 ms 4204 KB Output is correct
5 Correct 3 ms 4224 KB Output is correct
6 Correct 3 ms 4204 KB Output is correct
7 Correct 3 ms 4204 KB Output is correct
8 Correct 3 ms 4204 KB Output is correct
9 Correct 4 ms 4244 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 4 ms 4332 KB Output is correct
13 Correct 5 ms 4332 KB Output is correct
14 Correct 5 ms 4332 KB Output is correct
15 Correct 4 ms 4332 KB Output is correct
16 Correct 4 ms 4332 KB Output is correct
17 Correct 4 ms 4332 KB Output is correct
18 Correct 5 ms 4332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 3 ms 4204 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 4 ms 4204 KB Output is correct
7 Correct 3 ms 4204 KB Output is correct
8 Correct 3 ms 4204 KB Output is correct
9 Correct 3 ms 4204 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 4 ms 4204 KB Output is correct
12 Correct 4 ms 4204 KB Output is correct
13 Correct 3 ms 4204 KB Output is correct
14 Correct 3 ms 4204 KB Output is correct
15 Correct 4 ms 4204 KB Output is correct
16 Correct 3 ms 4224 KB Output is correct
17 Correct 3 ms 4204 KB Output is correct
18 Correct 3 ms 4224 KB Output is correct
19 Correct 3 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 3 ms 4204 KB Output is correct
5 Correct 3 ms 4224 KB Output is correct
6 Correct 3 ms 4204 KB Output is correct
7 Correct 3 ms 4204 KB Output is correct
8 Correct 3 ms 4204 KB Output is correct
9 Correct 4 ms 4244 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 4 ms 4332 KB Output is correct
13 Correct 5 ms 4332 KB Output is correct
14 Correct 5 ms 4332 KB Output is correct
15 Correct 4 ms 4332 KB Output is correct
16 Correct 4 ms 4332 KB Output is correct
17 Correct 4 ms 4332 KB Output is correct
18 Correct 5 ms 4332 KB Output is correct
19 Correct 3 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
21 Correct 3 ms 4204 KB Output is correct
22 Correct 3 ms 4204 KB Output is correct
23 Correct 3 ms 4204 KB Output is correct
24 Correct 4 ms 4204 KB Output is correct
25 Correct 3 ms 4204 KB Output is correct
26 Correct 3 ms 4204 KB Output is correct
27 Correct 3 ms 4204 KB Output is correct
28 Correct 3 ms 4204 KB Output is correct
29 Correct 4 ms 4204 KB Output is correct
30 Correct 4 ms 4204 KB Output is correct
31 Correct 3 ms 4204 KB Output is correct
32 Correct 3 ms 4204 KB Output is correct
33 Correct 4 ms 4204 KB Output is correct
34 Correct 3 ms 4224 KB Output is correct
35 Correct 3 ms 4204 KB Output is correct
36 Correct 3 ms 4224 KB Output is correct
37 Correct 3 ms 4204 KB Output is correct
38 Correct 3 ms 4204 KB Output is correct
39 Correct 15 ms 4332 KB Output is correct
40 Correct 4 ms 4224 KB Output is correct
41 Correct 3 ms 4204 KB Output is correct
42 Correct 3 ms 4216 KB Output is correct
43 Correct 4 ms 4204 KB Output is correct
44 Correct 3 ms 4204 KB Output is correct
45 Correct 3 ms 4204 KB Output is correct
46 Correct 3 ms 4224 KB Output is correct
47 Correct 3 ms 4204 KB Output is correct
48 Correct 3 ms 4204 KB Output is correct
49 Correct 3 ms 4204 KB Output is correct
50 Correct 3 ms 4204 KB Output is correct
51 Correct 10 ms 4332 KB Output is correct
52 Correct 10 ms 4332 KB Output is correct
53 Correct 25 ms 4332 KB Output is correct
54 Correct 24 ms 4332 KB Output is correct
55 Correct 16 ms 4348 KB Output is correct
56 Correct 24 ms 4332 KB Output is correct
57 Correct 25 ms 4332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 3 ms 4204 KB Output is correct
5 Correct 3 ms 4224 KB Output is correct
6 Correct 3 ms 4204 KB Output is correct
7 Correct 3 ms 4204 KB Output is correct
8 Correct 3 ms 4204 KB Output is correct
9 Correct 4 ms 4244 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 4 ms 4332 KB Output is correct
13 Correct 5 ms 4332 KB Output is correct
14 Correct 5 ms 4332 KB Output is correct
15 Correct 4 ms 4332 KB Output is correct
16 Correct 4 ms 4332 KB Output is correct
17 Correct 4 ms 4332 KB Output is correct
18 Correct 5 ms 4332 KB Output is correct
19 Correct 3 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
21 Correct 3 ms 4204 KB Output is correct
22 Correct 3 ms 4204 KB Output is correct
23 Correct 3 ms 4204 KB Output is correct
24 Correct 4 ms 4204 KB Output is correct
25 Correct 3 ms 4204 KB Output is correct
26 Correct 3 ms 4204 KB Output is correct
27 Correct 3 ms 4204 KB Output is correct
28 Correct 3 ms 4204 KB Output is correct
29 Correct 4 ms 4204 KB Output is correct
30 Correct 4 ms 4204 KB Output is correct
31 Correct 3 ms 4204 KB Output is correct
32 Correct 3 ms 4204 KB Output is correct
33 Correct 4 ms 4204 KB Output is correct
34 Correct 3 ms 4224 KB Output is correct
35 Correct 3 ms 4204 KB Output is correct
36 Correct 3 ms 4224 KB Output is correct
37 Correct 3 ms 4204 KB Output is correct
38 Correct 3 ms 4204 KB Output is correct
39 Correct 15 ms 4332 KB Output is correct
40 Correct 4 ms 4224 KB Output is correct
41 Correct 3 ms 4204 KB Output is correct
42 Correct 3 ms 4216 KB Output is correct
43 Correct 4 ms 4204 KB Output is correct
44 Correct 3 ms 4204 KB Output is correct
45 Correct 3 ms 4204 KB Output is correct
46 Correct 3 ms 4224 KB Output is correct
47 Correct 3 ms 4204 KB Output is correct
48 Correct 3 ms 4204 KB Output is correct
49 Correct 3 ms 4204 KB Output is correct
50 Correct 3 ms 4204 KB Output is correct
51 Correct 10 ms 4332 KB Output is correct
52 Correct 10 ms 4332 KB Output is correct
53 Correct 25 ms 4332 KB Output is correct
54 Correct 24 ms 4332 KB Output is correct
55 Correct 16 ms 4348 KB Output is correct
56 Correct 24 ms 4332 KB Output is correct
57 Correct 25 ms 4332 KB Output is correct
58 Execution timed out 1096 ms 492 KB Time limit exceeded
59 Halted 0 ms 0 KB -