Submission #845721

# Submission time Handle Problem Language Result Execution time Memory
845721 2023-09-06T15:05:48 Z BamshooT K blocks (IZhO14_blocks) C++14
53 / 100
7 ms 43256 KB
#include <iostream>
#include <cstring>
#include <vector>

#define ll long long
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define fi first
#define se second
#define inf 1e18

using namespace std;

typedef pair <int, int> ii;

const int N = 1e5 + 9;
int n, k, a[N], dp[N][109];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   // freopen("nhap.inp", "r", stdin);
   // freopen("xuat.out", "w", stdout);
    cin >> n >> k;
    FOR(i, 1, n) cin >> a[i];
    if (n > 100) return 0;
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    FOR(t, 1, k)
        for (int i = t; i <= n; ++i) {
            int p = a[i];
            for (int j = i; j > 0; --j) {
                p = max(p, a[j]);
                dp[t][i] = min(dp[t][i], dp[t-1][j-1] +p);
            }
        }
    cout << dp[k][n];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 43100 KB Output is correct
2 Correct 5 ms 43096 KB Output is correct
3 Correct 5 ms 43100 KB Output is correct
4 Correct 6 ms 43100 KB Output is correct
5 Correct 6 ms 43100 KB Output is correct
6 Correct 6 ms 43100 KB Output is correct
7 Correct 6 ms 43100 KB Output is correct
8 Correct 6 ms 43096 KB Output is correct
9 Correct 6 ms 43100 KB Output is correct
10 Correct 6 ms 43100 KB Output is correct
11 Correct 6 ms 43100 KB Output is correct
12 Correct 6 ms 43124 KB Output is correct
13 Correct 6 ms 43096 KB Output is correct
14 Correct 6 ms 43100 KB Output is correct
15 Correct 6 ms 42904 KB Output is correct
16 Correct 6 ms 43096 KB Output is correct
17 Correct 6 ms 43100 KB Output is correct
18 Correct 6 ms 42964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 43108 KB Output is correct
2 Correct 6 ms 42964 KB Output is correct
3 Correct 5 ms 43096 KB Output is correct
4 Correct 5 ms 43100 KB Output is correct
5 Correct 6 ms 43100 KB Output is correct
6 Correct 5 ms 43128 KB Output is correct
7 Correct 6 ms 43096 KB Output is correct
8 Correct 6 ms 43100 KB Output is correct
9 Correct 6 ms 43100 KB Output is correct
10 Correct 6 ms 43100 KB Output is correct
11 Correct 6 ms 42936 KB Output is correct
12 Correct 6 ms 43100 KB Output is correct
13 Correct 6 ms 43100 KB Output is correct
14 Correct 5 ms 43100 KB Output is correct
15 Correct 5 ms 43100 KB Output is correct
16 Correct 5 ms 43100 KB Output is correct
17 Correct 5 ms 43100 KB Output is correct
18 Correct 6 ms 43100 KB Output is correct
19 Correct 6 ms 43100 KB Output is correct
20 Correct 5 ms 42956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 43100 KB Output is correct
2 Correct 5 ms 43096 KB Output is correct
3 Correct 5 ms 43100 KB Output is correct
4 Correct 6 ms 43100 KB Output is correct
5 Correct 6 ms 43100 KB Output is correct
6 Correct 6 ms 43100 KB Output is correct
7 Correct 6 ms 43100 KB Output is correct
8 Correct 6 ms 43096 KB Output is correct
9 Correct 6 ms 43100 KB Output is correct
10 Correct 6 ms 43100 KB Output is correct
11 Correct 6 ms 43100 KB Output is correct
12 Correct 6 ms 43124 KB Output is correct
13 Correct 6 ms 43096 KB Output is correct
14 Correct 6 ms 43100 KB Output is correct
15 Correct 6 ms 42904 KB Output is correct
16 Correct 6 ms 43096 KB Output is correct
17 Correct 6 ms 43100 KB Output is correct
18 Correct 6 ms 42964 KB Output is correct
19 Correct 6 ms 43108 KB Output is correct
20 Correct 6 ms 42964 KB Output is correct
21 Correct 5 ms 43096 KB Output is correct
22 Correct 5 ms 43100 KB Output is correct
23 Correct 6 ms 43100 KB Output is correct
24 Correct 5 ms 43128 KB Output is correct
25 Correct 6 ms 43096 KB Output is correct
26 Correct 6 ms 43100 KB Output is correct
27 Correct 6 ms 43100 KB Output is correct
28 Correct 6 ms 43100 KB Output is correct
29 Correct 6 ms 42936 KB Output is correct
30 Correct 6 ms 43100 KB Output is correct
31 Correct 6 ms 43100 KB Output is correct
32 Correct 5 ms 43100 KB Output is correct
33 Correct 5 ms 43100 KB Output is correct
34 Correct 5 ms 43100 KB Output is correct
35 Correct 5 ms 43100 KB Output is correct
36 Correct 6 ms 43100 KB Output is correct
37 Correct 6 ms 43100 KB Output is correct
38 Correct 5 ms 42956 KB Output is correct
39 Correct 6 ms 43100 KB Output is correct
40 Correct 6 ms 42956 KB Output is correct
41 Correct 6 ms 43256 KB Output is correct
42 Correct 6 ms 43100 KB Output is correct
43 Correct 6 ms 43100 KB Output is correct
44 Correct 6 ms 43100 KB Output is correct
45 Correct 5 ms 43096 KB Output is correct
46 Correct 5 ms 43100 KB Output is correct
47 Correct 6 ms 43100 KB Output is correct
48 Correct 6 ms 43100 KB Output is correct
49 Correct 6 ms 42920 KB Output is correct
50 Correct 6 ms 43100 KB Output is correct
51 Correct 6 ms 42912 KB Output is correct
52 Correct 5 ms 43100 KB Output is correct
53 Correct 6 ms 42932 KB Output is correct
54 Correct 7 ms 43096 KB Output is correct
55 Correct 6 ms 43100 KB Output is correct
56 Correct 6 ms 43100 KB Output is correct
57 Correct 7 ms 42872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 43100 KB Output is correct
2 Correct 5 ms 43096 KB Output is correct
3 Correct 5 ms 43100 KB Output is correct
4 Correct 6 ms 43100 KB Output is correct
5 Correct 6 ms 43100 KB Output is correct
6 Correct 6 ms 43100 KB Output is correct
7 Correct 6 ms 43100 KB Output is correct
8 Correct 6 ms 43096 KB Output is correct
9 Correct 6 ms 43100 KB Output is correct
10 Correct 6 ms 43100 KB Output is correct
11 Correct 6 ms 43100 KB Output is correct
12 Correct 6 ms 43124 KB Output is correct
13 Correct 6 ms 43096 KB Output is correct
14 Correct 6 ms 43100 KB Output is correct
15 Correct 6 ms 42904 KB Output is correct
16 Correct 6 ms 43096 KB Output is correct
17 Correct 6 ms 43100 KB Output is correct
18 Correct 6 ms 42964 KB Output is correct
19 Correct 6 ms 43108 KB Output is correct
20 Correct 6 ms 42964 KB Output is correct
21 Correct 5 ms 43096 KB Output is correct
22 Correct 5 ms 43100 KB Output is correct
23 Correct 6 ms 43100 KB Output is correct
24 Correct 5 ms 43128 KB Output is correct
25 Correct 6 ms 43096 KB Output is correct
26 Correct 6 ms 43100 KB Output is correct
27 Correct 6 ms 43100 KB Output is correct
28 Correct 6 ms 43100 KB Output is correct
29 Correct 6 ms 42936 KB Output is correct
30 Correct 6 ms 43100 KB Output is correct
31 Correct 6 ms 43100 KB Output is correct
32 Correct 5 ms 43100 KB Output is correct
33 Correct 5 ms 43100 KB Output is correct
34 Correct 5 ms 43100 KB Output is correct
35 Correct 5 ms 43100 KB Output is correct
36 Correct 6 ms 43100 KB Output is correct
37 Correct 6 ms 43100 KB Output is correct
38 Correct 5 ms 42956 KB Output is correct
39 Correct 6 ms 43100 KB Output is correct
40 Correct 6 ms 42956 KB Output is correct
41 Correct 6 ms 43256 KB Output is correct
42 Correct 6 ms 43100 KB Output is correct
43 Correct 6 ms 43100 KB Output is correct
44 Correct 6 ms 43100 KB Output is correct
45 Correct 5 ms 43096 KB Output is correct
46 Correct 5 ms 43100 KB Output is correct
47 Correct 6 ms 43100 KB Output is correct
48 Correct 6 ms 43100 KB Output is correct
49 Correct 6 ms 42920 KB Output is correct
50 Correct 6 ms 43100 KB Output is correct
51 Correct 6 ms 42912 KB Output is correct
52 Correct 5 ms 43100 KB Output is correct
53 Correct 6 ms 42932 KB Output is correct
54 Correct 7 ms 43096 KB Output is correct
55 Correct 6 ms 43100 KB Output is correct
56 Correct 6 ms 43100 KB Output is correct
57 Correct 7 ms 42872 KB Output is correct
58 Incorrect 2 ms 344 KB Output isn't correct
59 Halted 0 ms 0 KB -