#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = numeric_limits<int> :: max();
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, d, t; cin>>n>>d>>t;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++){
cin>>a[i];
}
vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(d + 1)));
for (int i = 1; i <= n; i++){
priority_queue<int, vector<int>, greater<int>> pq;
int tt = 0, cnt = 0;
for (int j = i; j <= n; j++){
pq.push(a[j] - tt);
int m = pq.top() + tt;
cnt += (m <= t);
dp[i][j][0] = cnt;
tt++;
}
}
for (int k = 1; k <= d; k++){
for (int i = 1; i <= n; i++){
for (int j = i + k; j <= n; j++){
dp[i][j][k] = inf;
for (int m = i + k - 1; m <= j - k; m++){
dp[i][j][k] = min(dp[i][j][k], dp[i][m][k - 1] + dp[m + 1][j][k - 1]);
}
}
}
}
cout<<dp[1][n][d]<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
295 ms |
14936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
420 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
295 ms |
14936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Runtime error |
297 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
295 ms |
14936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
295 ms |
14936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |