# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
637000 |
2022-08-31T04:29:43 Z |
bonk |
Stove (JOI18_stove) |
C++14 |
|
39 ms |
98252 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 5002;
int dp[N][N], a[N];
int n, k;
int f(int idx, int k){
if(k < 0) return INT_MAX;
if(idx > n) return 0;
int &cur = dp[idx][k];
if(cur != -1) return cur;
cur = INT_MAX;
for(int i = idx; i <= n; i++){
cur = min(cur, f(i + 1, k - 1) + a[i] - a[idx] + 1);
}
return cur;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
memset(dp, -1, sizeof(dp));
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
cout << f(1, k) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
98252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
98252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
98252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |