# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
850970 |
2023-09-18T04:00:57 Z |
NamPE |
Stove (JOI18_stove) |
C++17 |
|
1000 ms |
4440 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[(ll)(5e2 + 1)][(ll)(5e2 + 1)][2];
ll dfs(vector<ll>& a, ll i, ll k, ll state) {
if(i == a.size()) {
return (!state ? 0 : INT_MAX);
}
ll res = INT_MAX;
if(!state && k) {
res = min(res, dfs(a, i + 1, k - 1, 0) + 1);
res = min(res, dfs(a, i + 1, k - 1, 1) - a[i]);
} else if(state) {
res = min(res, dfs(a, i + 1, k, 1));
res = min(res, dfs(a, i + 1, k, 0) + a[i] + 1);
}
return res;
}
int main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
memset(dp, -1, sizeof dp);
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for(ll& i : a) {
cin >> i;
}
cout << dfs(a, 0, k, 0);
}
Compilation message
stove.cpp: In function 'll dfs(std::vector<long long int>&, ll, ll, ll)':
stove.cpp:9:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | if(i == a.size()) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4184 KB |
Output is correct |
2 |
Correct |
2 ms |
4188 KB |
Output is correct |
3 |
Correct |
2 ms |
4184 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4184 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4388 KB |
Output is correct |
8 |
Correct |
6 ms |
4184 KB |
Output is correct |
9 |
Correct |
1 ms |
4184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4184 KB |
Output is correct |
2 |
Correct |
2 ms |
4188 KB |
Output is correct |
3 |
Correct |
2 ms |
4184 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4184 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4388 KB |
Output is correct |
8 |
Correct |
6 ms |
4184 KB |
Output is correct |
9 |
Correct |
1 ms |
4184 KB |
Output is correct |
10 |
Execution timed out |
1050 ms |
4440 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4184 KB |
Output is correct |
2 |
Correct |
2 ms |
4188 KB |
Output is correct |
3 |
Correct |
2 ms |
4184 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4184 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4388 KB |
Output is correct |
8 |
Correct |
6 ms |
4184 KB |
Output is correct |
9 |
Correct |
1 ms |
4184 KB |
Output is correct |
10 |
Execution timed out |
1050 ms |
4440 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |