This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ve vector
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 10;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, d, t;
ve<int> T;
ve<ve<int>> DP;
cin >> n >> d >> t;
T = ve<int>(n);
DP = ve<ve<int>>(d + 1, ve<int>(n, INF));
for (int i = 0; i < n; i++) {
cin >> T[i];
}
DP[0][n - 1] = 0;
for (int i = 1; i <= d; i++) {
for (int j = n - 2; j >= 0; j--) {
int z = INF;
int cnt = 0;
for (int k = j + 1; k < n; k++) {
if (T[k] <= t || z <= t) cnt++;
z = min(z, T[k]);
z++;
DP[i][j] = min(DP[i][j], DP[i - 1][k] + cnt);
}
}
}
int ans = INF;
int z = INF;
int cnt = 0;
for (int i = 0; i < n; i++) {
if (T[i] <= t || z <= t) cnt++;
z = min(z, T[i]);
z++;
ans = min(ans, DP[d][i] + cnt);
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |