Submission #337226

# Submission time Handle Problem Language Result Execution time Memory
337226 2020-12-19T01:51:15 Z boykut K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

int dp[100001][101], a[100001];

signed main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   
   int n, k;
   cin >> n >> k;
   
   for (int i = 1; i <= n; i++) {
      cin >> a[i];
   }
   
   for (int i = 1; i <= n; i++) {
      dp[i][1] = max(dp[i - 1][1], a[i]);
   }
   
   auto getmax = [&](int l, int r) -> int{
      int mx = INT_MIN;
      for (int i = l; i <= r; i++) 
         mx = max(mx, a[i]);
      return mx;
   };
   
   for (int j = 2; j <= k; j++) {
      for (int i = 1; i <= n; i++) {
         int mn = INT_MAX;
         for (int l = 1; l < i; l++) {
            mn = min(mn, dp[l][j - 1] + getmax(l + 1, i));
         }
         dp[i][j] = mn;
      }
   }
   
   cout << dp[n][k] << '\n';
   
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 380 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 380 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 380 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -