답안 #337223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337223 2020-12-19T01:46:14 Z boykut K개의 묶음 (IZhO14_blocks) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>

using namespace std;

int dp[100001][101];

signed main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   
   int n, k;
   cin >> n >> k;
   int a[1 + n]; a[0] = 0;
   
   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{
      return *max_element(a + l, a + r + 1);
   };
   
   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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 364 KB Output is correct
5 Correct 0 ms 364 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -