# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636999 | 2022-08-31T04:29:12 Z | bonk | Stove (JOI18_stove) | C++14 | 36 ms | 98192 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 1e18; if(idx > n) return 0; int &cur = dp[idx][k]; if(cur != -1) return cur; cur = INT_MAX; 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; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 98192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 98192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 98192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |