# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119640 | 2024-11-27T08:57:08 Z | luvna | K blocks (IZhO14_blocks) | C++14 | 1000 ms | 79572 KB |
#include<bits/stdc++.h> #define MASK(i) (1 << (i)) #define pub push_back #define all(v) v.begin(), v.end() #define compact(v) v.erase(unique(all(v)), end(v)) #define pii pair<int,int> #define fi first #define se second #define endl "\n" #define sz(v) (int)(v).size() #define dbg(x) "[" #x " = " << (x) << "]" #define int long long using namespace std; template<class T> bool minimize(T& a, T b){if(a > b) return a = b, true;return false;} template<class T> bool maximize(T& a, T b){if(a < b) return a = b, true;return false;} typedef long long ll; typedef long double ld; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rand(ll l, ll r){return uniform_int_distribution<ll>(l, r)(rng);} const int N = 1e5 + 15; const int MOD = 1e9 + 7; int n, k; int dp[N][101]; void solve(){ cin >> n >> k; vector<int> a(n + 15, 0); for(int i = 1; i <= n; i++) cin >> a[i]; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for(int K = 1; K <= k; K++){ for(int i = 1; i <= n; i++){ int mx = a[i]; for(int j = i; j >= 1; j--){ maximize(mx, a[j]); minimize(dp[i][K], dp[j-1][K-1] + mx); } } } cout << dp[n][k]; } signed main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "task" if(fopen(task".INP", "r")){ freopen(task".INP", "r", stdin); freopen(task".OUT", "w", stdout); } int t; t = 1; //cin >> t; while(t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 79372 KB | Output is correct |
2 | Correct | 64 ms | 79296 KB | Output is correct |
3 | Correct | 63 ms | 79432 KB | Output is correct |
4 | Correct | 65 ms | 79432 KB | Output is correct |
5 | Correct | 62 ms | 79384 KB | Output is correct |
6 | Correct | 57 ms | 79572 KB | Output is correct |
7 | Correct | 55 ms | 79436 KB | Output is correct |
8 | Correct | 52 ms | 79436 KB | Output is correct |
9 | Correct | 57 ms | 79444 KB | Output is correct |
10 | Correct | 67 ms | 79440 KB | Output is correct |
11 | Correct | 61 ms | 79324 KB | Output is correct |
12 | Correct | 60 ms | 79436 KB | Output is correct |
13 | Correct | 62 ms | 79320 KB | Output is correct |
14 | Correct | 60 ms | 79284 KB | Output is correct |
15 | Correct | 63 ms | 79436 KB | Output is correct |
16 | Correct | 56 ms | 79308 KB | Output is correct |
17 | Correct | 58 ms | 79436 KB | Output is correct |
18 | Correct | 61 ms | 79436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 71 ms | 79432 KB | Output is correct |
2 | Correct | 59 ms | 79496 KB | Output is correct |
3 | Correct | 62 ms | 79364 KB | Output is correct |
4 | Correct | 58 ms | 79432 KB | Output is correct |
5 | Correct | 68 ms | 79432 KB | Output is correct |
6 | Correct | 65 ms | 79400 KB | Output is correct |
7 | Correct | 60 ms | 79436 KB | Output is correct |
8 | Correct | 61 ms | 79436 KB | Output is correct |
9 | Correct | 66 ms | 79436 KB | Output is correct |
10 | Correct | 59 ms | 79308 KB | Output is correct |
11 | Correct | 59 ms | 79516 KB | Output is correct |
12 | Correct | 52 ms | 79376 KB | Output is correct |
13 | Correct | 54 ms | 79444 KB | Output is correct |
14 | Correct | 60 ms | 79436 KB | Output is correct |
15 | Correct | 56 ms | 79436 KB | Output is correct |
16 | Correct | 55 ms | 79320 KB | Output is correct |
17 | Correct | 55 ms | 79436 KB | Output is correct |
18 | Correct | 59 ms | 79436 KB | Output is correct |
19 | Correct | 53 ms | 79380 KB | Output is correct |
20 | Correct | 60 ms | 79340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 79372 KB | Output is correct |
2 | Correct | 64 ms | 79296 KB | Output is correct |
3 | Correct | 63 ms | 79432 KB | Output is correct |
4 | Correct | 65 ms | 79432 KB | Output is correct |
5 | Correct | 62 ms | 79384 KB | Output is correct |
6 | Correct | 57 ms | 79572 KB | Output is correct |
7 | Correct | 55 ms | 79436 KB | Output is correct |
8 | Correct | 52 ms | 79436 KB | Output is correct |
9 | Correct | 57 ms | 79444 KB | Output is correct |
10 | Correct | 67 ms | 79440 KB | Output is correct |
11 | Correct | 61 ms | 79324 KB | Output is correct |
12 | Correct | 60 ms | 79436 KB | Output is correct |
13 | Correct | 62 ms | 79320 KB | Output is correct |
14 | Correct | 60 ms | 79284 KB | Output is correct |
15 | Correct | 63 ms | 79436 KB | Output is correct |
16 | Correct | 56 ms | 79308 KB | Output is correct |
17 | Correct | 58 ms | 79436 KB | Output is correct |
18 | Correct | 61 ms | 79436 KB | Output is correct |
19 | Correct | 71 ms | 79432 KB | Output is correct |
20 | Correct | 59 ms | 79496 KB | Output is correct |
21 | Correct | 62 ms | 79364 KB | Output is correct |
22 | Correct | 58 ms | 79432 KB | Output is correct |
23 | Correct | 68 ms | 79432 KB | Output is correct |
24 | Correct | 65 ms | 79400 KB | Output is correct |
25 | Correct | 60 ms | 79436 KB | Output is correct |
26 | Correct | 61 ms | 79436 KB | Output is correct |
27 | Correct | 66 ms | 79436 KB | Output is correct |
28 | Correct | 59 ms | 79308 KB | Output is correct |
29 | Correct | 59 ms | 79516 KB | Output is correct |
30 | Correct | 52 ms | 79376 KB | Output is correct |
31 | Correct | 54 ms | 79444 KB | Output is correct |
32 | Correct | 60 ms | 79436 KB | Output is correct |
33 | Correct | 56 ms | 79436 KB | Output is correct |
34 | Correct | 55 ms | 79320 KB | Output is correct |
35 | Correct | 55 ms | 79436 KB | Output is correct |
36 | Correct | 59 ms | 79436 KB | Output is correct |
37 | Correct | 53 ms | 79380 KB | Output is correct |
38 | Correct | 60 ms | 79340 KB | Output is correct |
39 | Correct | 59 ms | 79316 KB | Output is correct |
40 | Correct | 53 ms | 79436 KB | Output is correct |
41 | Correct | 56 ms | 79436 KB | Output is correct |
42 | Correct | 54 ms | 79312 KB | Output is correct |
43 | Correct | 54 ms | 79416 KB | Output is correct |
44 | Correct | 53 ms | 79444 KB | Output is correct |
45 | Correct | 54 ms | 79416 KB | Output is correct |
46 | Correct | 61 ms | 79404 KB | Output is correct |
47 | Correct | 55 ms | 79436 KB | Output is correct |
48 | Correct | 60 ms | 79436 KB | Output is correct |
49 | Correct | 58 ms | 79444 KB | Output is correct |
50 | Correct | 55 ms | 79420 KB | Output is correct |
51 | Correct | 58 ms | 79432 KB | Output is correct |
52 | Correct | 66 ms | 79352 KB | Output is correct |
53 | Correct | 69 ms | 79404 KB | Output is correct |
54 | Correct | 58 ms | 79324 KB | Output is correct |
55 | Correct | 68 ms | 79436 KB | Output is correct |
56 | Correct | 65 ms | 79436 KB | Output is correct |
57 | Correct | 65 ms | 79388 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 79372 KB | Output is correct |
2 | Correct | 64 ms | 79296 KB | Output is correct |
3 | Correct | 63 ms | 79432 KB | Output is correct |
4 | Correct | 65 ms | 79432 KB | Output is correct |
5 | Correct | 62 ms | 79384 KB | Output is correct |
6 | Correct | 57 ms | 79572 KB | Output is correct |
7 | Correct | 55 ms | 79436 KB | Output is correct |
8 | Correct | 52 ms | 79436 KB | Output is correct |
9 | Correct | 57 ms | 79444 KB | Output is correct |
10 | Correct | 67 ms | 79440 KB | Output is correct |
11 | Correct | 61 ms | 79324 KB | Output is correct |
12 | Correct | 60 ms | 79436 KB | Output is correct |
13 | Correct | 62 ms | 79320 KB | Output is correct |
14 | Correct | 60 ms | 79284 KB | Output is correct |
15 | Correct | 63 ms | 79436 KB | Output is correct |
16 | Correct | 56 ms | 79308 KB | Output is correct |
17 | Correct | 58 ms | 79436 KB | Output is correct |
18 | Correct | 61 ms | 79436 KB | Output is correct |
19 | Correct | 71 ms | 79432 KB | Output is correct |
20 | Correct | 59 ms | 79496 KB | Output is correct |
21 | Correct | 62 ms | 79364 KB | Output is correct |
22 | Correct | 58 ms | 79432 KB | Output is correct |
23 | Correct | 68 ms | 79432 KB | Output is correct |
24 | Correct | 65 ms | 79400 KB | Output is correct |
25 | Correct | 60 ms | 79436 KB | Output is correct |
26 | Correct | 61 ms | 79436 KB | Output is correct |
27 | Correct | 66 ms | 79436 KB | Output is correct |
28 | Correct | 59 ms | 79308 KB | Output is correct |
29 | Correct | 59 ms | 79516 KB | Output is correct |
30 | Correct | 52 ms | 79376 KB | Output is correct |
31 | Correct | 54 ms | 79444 KB | Output is correct |
32 | Correct | 60 ms | 79436 KB | Output is correct |
33 | Correct | 56 ms | 79436 KB | Output is correct |
34 | Correct | 55 ms | 79320 KB | Output is correct |
35 | Correct | 55 ms | 79436 KB | Output is correct |
36 | Correct | 59 ms | 79436 KB | Output is correct |
37 | Correct | 53 ms | 79380 KB | Output is correct |
38 | Correct | 60 ms | 79340 KB | Output is correct |
39 | Correct | 59 ms | 79316 KB | Output is correct |
40 | Correct | 53 ms | 79436 KB | Output is correct |
41 | Correct | 56 ms | 79436 KB | Output is correct |
42 | Correct | 54 ms | 79312 KB | Output is correct |
43 | Correct | 54 ms | 79416 KB | Output is correct |
44 | Correct | 53 ms | 79444 KB | Output is correct |
45 | Correct | 54 ms | 79416 KB | Output is correct |
46 | Correct | 61 ms | 79404 KB | Output is correct |
47 | Correct | 55 ms | 79436 KB | Output is correct |
48 | Correct | 60 ms | 79436 KB | Output is correct |
49 | Correct | 58 ms | 79444 KB | Output is correct |
50 | Correct | 55 ms | 79420 KB | Output is correct |
51 | Correct | 58 ms | 79432 KB | Output is correct |
52 | Correct | 66 ms | 79352 KB | Output is correct |
53 | Correct | 69 ms | 79404 KB | Output is correct |
54 | Correct | 58 ms | 79324 KB | Output is correct |
55 | Correct | 68 ms | 79436 KB | Output is correct |
56 | Correct | 65 ms | 79436 KB | Output is correct |
57 | Correct | 65 ms | 79388 KB | Output is correct |
58 | Execution timed out | 1046 ms | 79436 KB | Time limit exceeded |
59 | Halted | 0 ms | 0 KB | - |