Submission #369481

# Submission time Handle Problem Language Result Execution time Memory
369481 2021-02-21T18:29:14 Z MilosMilutinovic K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const int inf = (int) 1e9;
  vector<vector<int>> dp(n, vector<int>(k, inf));
  int curr = 0;
  for (int i = 0; i < n; i++) {
    curr = max(curr, a[i]);
    dp[i][0] = curr;
  }
  for (int i = 1; i < k; i++) {
    for (int j = 0; j < n; j++) {
      int mx = a[j];
      for (int l = j - 1; l >= 0; l--) {
        mx = max(mx, a[l]);
        dp[j][i] = min(dp[j][i], dp[l][i - 1] + mx);
      }
    }
  }
  cout << dp[n - 1][k - 1] << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -