Submission #870013

# Submission time Handle Problem Language Result Execution time Memory
870013 2023-11-06T15:54:55 Z truongdoan2012 K blocks (IZhO14_blocks) C++17
0 / 100
16 ms 80084 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];

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

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int TC = 1;
  // cin >> TC;
  while (TC--) {
    solve();
  }
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 79964 KB Output is correct
2 Correct 11 ms 79960 KB Output is correct
3 Correct 10 ms 79964 KB Output is correct
4 Correct 10 ms 80084 KB Output is correct
5 Correct 10 ms 79964 KB Output is correct
6 Correct 10 ms 79960 KB Output is correct
7 Correct 10 ms 79964 KB Output is correct
8 Correct 10 ms 80080 KB Output is correct
9 Correct 10 ms 79964 KB Output is correct
10 Incorrect 10 ms 79964 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 79964 KB Output is correct
2 Correct 10 ms 80080 KB Output is correct
3 Correct 9 ms 79964 KB Output is correct
4 Correct 10 ms 79960 KB Output is correct
5 Correct 10 ms 79964 KB Output is correct
6 Correct 10 ms 79904 KB Output is correct
7 Correct 10 ms 79964 KB Output is correct
8 Correct 10 ms 79884 KB Output is correct
9 Correct 10 ms 79964 KB Output is correct
10 Incorrect 10 ms 79964 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 79964 KB Output is correct
2 Correct 11 ms 79960 KB Output is correct
3 Correct 10 ms 79964 KB Output is correct
4 Correct 10 ms 80084 KB Output is correct
5 Correct 10 ms 79964 KB Output is correct
6 Correct 10 ms 79960 KB Output is correct
7 Correct 10 ms 79964 KB Output is correct
8 Correct 10 ms 80080 KB Output is correct
9 Correct 10 ms 79964 KB Output is correct
10 Incorrect 10 ms 79964 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 79964 KB Output is correct
2 Correct 11 ms 79960 KB Output is correct
3 Correct 10 ms 79964 KB Output is correct
4 Correct 10 ms 80084 KB Output is correct
5 Correct 10 ms 79964 KB Output is correct
6 Correct 10 ms 79960 KB Output is correct
7 Correct 10 ms 79964 KB Output is correct
8 Correct 10 ms 80080 KB Output is correct
9 Correct 10 ms 79964 KB Output is correct
10 Incorrect 10 ms 79964 KB Output isn't correct
11 Halted 0 ms 0 KB -