# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
637001 |
2022-08-31T04:31:32 Z |
bonk |
Stove (JOI18_stove) |
C++14 |
|
344 ms |
98212 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 2e9;
if(idx > n) return 0;
int &cur = dp[idx][k];
if(cur != -1) return cur;
cur = 2e9;
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 |
Correct |
36 ms |
98124 KB |
Output is correct |
2 |
Correct |
36 ms |
98120 KB |
Output is correct |
3 |
Correct |
36 ms |
98160 KB |
Output is correct |
4 |
Correct |
36 ms |
98172 KB |
Output is correct |
5 |
Correct |
41 ms |
98212 KB |
Output is correct |
6 |
Correct |
36 ms |
98176 KB |
Output is correct |
7 |
Correct |
36 ms |
98124 KB |
Output is correct |
8 |
Correct |
36 ms |
98104 KB |
Output is correct |
9 |
Correct |
36 ms |
98200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
98124 KB |
Output is correct |
2 |
Correct |
36 ms |
98120 KB |
Output is correct |
3 |
Correct |
36 ms |
98160 KB |
Output is correct |
4 |
Correct |
36 ms |
98172 KB |
Output is correct |
5 |
Correct |
41 ms |
98212 KB |
Output is correct |
6 |
Correct |
36 ms |
98176 KB |
Output is correct |
7 |
Correct |
36 ms |
98124 KB |
Output is correct |
8 |
Correct |
36 ms |
98104 KB |
Output is correct |
9 |
Correct |
36 ms |
98200 KB |
Output is correct |
10 |
Incorrect |
344 ms |
98124 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
98124 KB |
Output is correct |
2 |
Correct |
36 ms |
98120 KB |
Output is correct |
3 |
Correct |
36 ms |
98160 KB |
Output is correct |
4 |
Correct |
36 ms |
98172 KB |
Output is correct |
5 |
Correct |
41 ms |
98212 KB |
Output is correct |
6 |
Correct |
36 ms |
98176 KB |
Output is correct |
7 |
Correct |
36 ms |
98124 KB |
Output is correct |
8 |
Correct |
36 ms |
98104 KB |
Output is correct |
9 |
Correct |
36 ms |
98200 KB |
Output is correct |
10 |
Incorrect |
344 ms |
98124 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |