# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996478 |
2024-06-10T17:02:21 Z |
overwatch9 |
Stove (JOI18_stove) |
C++17 |
|
1 ms |
2652 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;
int N, K;
vector <int> t;
const int maxn = 5000 + 1;
ll dp[maxn][maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
t.resize(N+1);
for (int i = 1; i <= N; i++)
cin >> t[i];
ll ans = 1e18;
for (int i = 0; i <= N; i++) {
fill(dp[i]+1, dp[i] + maxn, 1e18);
}
dp[0][0] = 0;
set <ll> s;
for (int j = 1; j <= K; j++) {
for (int i = 1; i <= N; i++) {
if (j == 1 || i == 1)
s.insert(0);
else
s.insert(dp[i-1][j-1] - t[i] + 1);
dp[i][j] = *s.begin() + t[i];
if (i == N)
ans = min(ans, dp[i][j]);
}
s.clear();
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |