# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100926 |
2024-10-15T04:08:42 Z |
akzytr |
Stove (JOI18_stove) |
C++17 |
|
1 ms |
504 KB |
#include <bits/stdc++.h>
using namespace std;
template <typename T> using ve = vector<T>;
template <typename T, int sz> using ar = array<T, sz>;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define endl '\n'
int main() {
int N, K;
cin >> N >> K;
int ti[22] = {};
for(int i = 0; i < N; i++) {
int x;
cin >> x;
ti[x] = 1;
}
int dp[22][22][2];
for(int i = 0; i < 22; i++) {
for(int j = 0; j < 22; j++) {
dp[i][j][0] = (int)1e9;
dp[i][j][1] = (int)1e9;
}
}
for(int i = 21; i >= 1; i--) {
if(ti[i]) {
break;
}
for(int k = 0; k <= K; k++) {
dp[i][k][0] = 0;
}
}
for(int i = 21; i >= 1; i--) {
for(int left = K; left >= 1; left--) {
// ON
if(ti[i]) {
for(int j = i + 1; j <= 21; j++) {
dp[i][left][1] = min(dp[i][left][1], dp[j][left - 1][0] + j - i);
}
} else {
for(int j = i + 1; j <= 21; j++) {
if(ti[j] == 1) {
dp[i][left][0] = min(dp[i][left][0], dp[j][left][1]);
break;
}
}
}
}
}
cout << min(dp[1][K][0], dp[1][K][1]) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |