Submission #745983

# Submission time Handle Problem Language Result Execution time Memory
745983 2023-05-21T10:23:23 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
44 ms 35188 KB
#include <bits/stdc++.h>
using namespace std;

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

int dp[MAXN][MAXN*MAXN+100];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n+1), b(n+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++) {
		dp[i][0] = true;
		for (int j = b[i]; j < MAXS; j++) {
			if (dp[i-1][j-b[i]]) {
				dp[i][j] = true;
			}
		}
	}
	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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 35188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -