Submission #746005

# Submission time Handle Problem Language Result Execution time Memory
746005 2023-05-21T10:30:41 Z vjudge1 Kitchen (BOI19_kitchen) C++17
20 / 100
289 ms 108248 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 301;
const int MAXS = MAXN*MAXN+1000;

int dp[MAXN][MAXS];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n+1), b(m+1);
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; sum += a[i];
	}
	for (int j = 1; j <= m; j++) {
		cin >> b[j];
	}
	
	dp[0][0] = true;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < MAXS; j++) {
			dp[i][j] = dp[i-1][j];
		}
		for (int j = b[i]; j < MAXS; j++) {
			if (dp[i-1][j-b[i]]) {
				dp[i][j] = true;
			}
		}
	}
	for (int i = 0; i < MAXS; i++) {
		if (dp[m][i]) cerr << i << " ";
	}
	for (int i = sum; i < MAXS; i++) {
		if (dp[m][i]) {
			cout << i-sum << "\n";
			return 0;
		}
	}
	cout << "Impossible\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 140 ms 94036 KB Output is correct
2 Correct 136 ms 81480 KB Output is correct
3 Correct 184 ms 108148 KB Output is correct
4 Correct 289 ms 108248 KB Output is correct
5 Correct 245 ms 104728 KB Output is correct
6 Correct 112 ms 75044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 14564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 964 KB Output isn't correct
5 Halted 0 ms 0 KB -