# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
866599 |
2023-10-26T13:27:07 Z |
maks007 |
Stove (JOI18_stove) |
C++14 |
|
1000 ms |
23896 KB |
#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main () {
int n, k;
cin >> n >> k;
vector <int> a(n + 1);
for(int i = 1; i <= n; i ++) cin >> a[i];
vector <vector <int> > dp(n + 1, vector <int> (k + 1, 1e9));
dp[0][0] = 0;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= k; j ++) {
// dp[i][j] = min({dp[i][j], dp[i][j-1]});
for(int I = 0; I < i; I ++)
dp[i][j] = min(dp[I][j-1]+(a[i]-a[I+1]+1), dp[i][j]);
}
}
cout << dp[n][k];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
59 ms |
816 KB |
Output is correct |
11 |
Correct |
655 ms |
2924 KB |
Output is correct |
12 |
Execution timed out |
1033 ms |
23896 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
59 ms |
816 KB |
Output is correct |
11 |
Correct |
655 ms |
2924 KB |
Output is correct |
12 |
Execution timed out |
1033 ms |
23896 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |