답안 #874958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874958 2023-11-18T09:50:11 Z TAhmed33 Kitchen (BOI19_kitchen) C++
100 / 100
54 ms 106408 KB
#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[301], b[301];
int dp[301][90001];
void bad () {
	cout << "Impossible\n";
	exit(0);
}
int main () {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int j = 0; j < m; j++) cin >> b[j];
	int pp = *min_element(a, a + n);
	if (pp < k || m < k) bad();
	for (int i = 1; i <= 90000; i++) dp[0][i] = -1e9;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j <= 90000; j++) {
			if (j < b[i - 1]) {
				dp[i][j] = dp[i - 1][j]; continue;
			}
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - b[i - 1]] + min(b[i - 1], n));
		}
	}
	int mn = 1e9; int sum = 0; for (int i = 0; i < n; i++) sum += a[i];
	for (int i = sum; i <= 90000; i++) {
		if (dp[m][i] >= n * k) {
			mn = i; break;
		}
	}
	mn -= sum;
	if (mn >= 1e8) bad();
	cout << mn << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 3 ms 6748 KB Output is correct
11 Correct 2 ms 6588 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 92868 KB Output is correct
2 Correct 28 ms 80464 KB Output is correct
3 Correct 40 ms 106408 KB Output is correct
4 Correct 39 ms 106244 KB Output is correct
5 Correct 36 ms 102996 KB Output is correct
6 Correct 33 ms 74640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 14936 KB Output is correct
2 Correct 5 ms 14940 KB Output is correct
3 Correct 6 ms 14940 KB Output is correct
4 Correct 5 ms 14988 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 3 ms 6748 KB Output is correct
11 Correct 2 ms 6588 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
14 Correct 54 ms 92868 KB Output is correct
15 Correct 28 ms 80464 KB Output is correct
16 Correct 40 ms 106408 KB Output is correct
17 Correct 39 ms 106244 KB Output is correct
18 Correct 36 ms 102996 KB Output is correct
19 Correct 33 ms 74640 KB Output is correct
20 Correct 5 ms 14936 KB Output is correct
21 Correct 5 ms 14940 KB Output is correct
22 Correct 6 ms 14940 KB Output is correct
23 Correct 5 ms 14988 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 27 ms 76368 KB Output is correct
26 Correct 32 ms 86616 KB Output is correct
27 Correct 20 ms 57936 KB Output is correct
28 Correct 33 ms 86868 KB Output is correct
29 Correct 31 ms 88668 KB Output is correct
30 Correct 38 ms 106372 KB Output is correct