Submission #312207

# Submission time Handle Problem Language Result Execution time Memory
312207 2020-10-12T17:28:11 Z tevdore K blocks (IZhO14_blocks) C++14
0 / 100
46 ms 79408 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, k;
long long a[N], dp[N][101];
int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= 100; j++) dp[i][j] = 1e18;
    }
    dp[0][0] = 0;
    long long mx = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= k; j++) {
            mx = a[i];
            for(int l = i - 1; l >= j - 1; l--) {
                dp[i][j] = min(dp[i][j], dp[l][j - 1] + mx);
                mx = max(mx, a[l]);
            }
        }
    }
    cout << dp[n][k] << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 79352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 79408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 79352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 79352 KB Output isn't correct
2 Halted 0 ms 0 KB -