Submission #948239

# Submission time Handle Problem Language Result Execution time Memory
948239 2024-03-18T01:08:42 Z brendonw Rabbit Carrot (LMIO19_triusis) C++17
35 / 100
163 ms 196860 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAX_A = 5e3;

int solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto &a_i: a) {
		cin >> a_i;
	}
	vector<vector<int>> dp(n + 1, vector<int>(MAX_A + 1, 3e5));
	dp[0] = {0};
	vector<vector<int>> suffix(n + 1, vector<int>(MAX_A + 2, 3e5));
	suffix[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int h = MAX_A; h >= 0; --h) {
			dp[i][h] = (a[i - 1] != h) + suffix[i - 1][max(h - m, 0)];
			suffix[i][h] = min(suffix[i][h + 1], dp[i][h]);
		}
	}
	cout << *min_element(dp[n].begin(), dp[n].end());

	return 0;
}

#ifndef MY_UNIT_TEST

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}

#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 856 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 856 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 131 ms 159132 KB Output is correct
21 Correct 150 ms 196468 KB Output is correct
22 Correct 150 ms 196616 KB Output is correct
23 Correct 146 ms 196620 KB Output is correct
24 Correct 148 ms 196432 KB Output is correct
25 Correct 148 ms 196364 KB Output is correct
26 Correct 150 ms 196620 KB Output is correct
27 Correct 147 ms 196436 KB Output is correct
28 Correct 148 ms 196432 KB Output is correct
29 Correct 150 ms 196860 KB Output is correct
30 Correct 149 ms 196368 KB Output is correct
31 Correct 148 ms 196436 KB Output is correct
32 Correct 146 ms 196688 KB Output is correct
33 Correct 147 ms 196620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 131 ms 159132 KB Output is correct
5 Correct 150 ms 196468 KB Output is correct
6 Correct 150 ms 196616 KB Output is correct
7 Correct 146 ms 196620 KB Output is correct
8 Correct 148 ms 196432 KB Output is correct
9 Correct 148 ms 196364 KB Output is correct
10 Correct 150 ms 196620 KB Output is correct
11 Correct 147 ms 196436 KB Output is correct
12 Correct 148 ms 196432 KB Output is correct
13 Correct 150 ms 196860 KB Output is correct
14 Correct 149 ms 196368 KB Output is correct
15 Correct 148 ms 196436 KB Output is correct
16 Correct 146 ms 196688 KB Output is correct
17 Correct 147 ms 196620 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 1112 KB Output is correct
24 Correct 1 ms 860 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 1 ms 856 KB Output is correct
32 Correct 1 ms 860 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 146 ms 196432 KB Output is correct
35 Incorrect 163 ms 196648 KB Output isn't correct
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 196432 KB Output is correct
2 Incorrect 163 ms 196648 KB Output isn't correct
3 Halted 0 ms 0 KB -