Submission #645241

# Submission time Handle Problem Language Result Execution time Memory
645241 2022-09-26T13:43:04 Z someone K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 1108 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5 + 42, K = 110, INF = 1e18 + 42;

int n, k, a[N], pre[N], dp[K][N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> k;
    n++;
    a[0] = INF;
    vector<int> imax(1);
    for(int i = 1; i < n; i++) {
        cin >> a[i];
        while(a[imax.back()] < a[i])
            imax.pop_back();
        pre[i] = imax.back();
        imax.push_back(i);
    }
    for(int i = 1; i < N; i++)
        dp[0][i] = INF;
    for(int i = 1; i <= k; i++) {
        dp[i][i-1] = INF;
        for(int j = i; j < n; j++) {
            pre[j] = max(pre[j], i-1);
            dp[i][j] = min(a[j] + dp[i-1][pre[j]], dp[i][pre[j]]);
        }
    }
    cout << dp[k][n-1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Incorrect 1 ms 1108 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1096 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1092 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1092 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Incorrect 1 ms 1108 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Incorrect 1 ms 1108 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Incorrect 1 ms 1108 KB Output isn't correct
14 Halted 0 ms 0 KB -