Submission #1112837

# Submission time Handle Problem Language Result Execution time Memory
1112837 2024-11-15T02:40:53 Z Pwo Stove (JOI18_stove) C++17
50 / 100
224 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, k; cin >> n >> k;
	int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = a[1];
	
	int dp[n + 1][k + 1]{}; dp[0][1] = 1e18;
	for (int i = 1; i <= n; i++) for (int j = 0; j <= k; j++) {
		if (i < j || j == 0) { dp[i][j] = 1e18; continue; }
		dp[i][j] = min(dp[i - 1][j] + a[i] - a[i - 1], dp[i - 1][j - 1] + 1);
	}
	
	cout << dp[n][k];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 572 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 504 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 572 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 4 ms 2640 KB Output is correct
12 Correct 29 ms 23996 KB Output is correct
13 Correct 65 ms 47432 KB Output is correct
14 Correct 71 ms 68424 KB Output is correct
15 Correct 75 ms 70728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 572 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 4 ms 2640 KB Output is correct
12 Correct 29 ms 23996 KB Output is correct
13 Correct 65 ms 47432 KB Output is correct
14 Correct 71 ms 68424 KB Output is correct
15 Correct 75 ms 70728 KB Output is correct
16 Correct 17 ms 10568 KB Output is correct
17 Correct 87 ms 81220 KB Output is correct
18 Runtime error 224 ms 262144 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -