Submission #783860

# Submission time Handle Problem Language Result Execution time Memory
783860 2023-07-15T11:30:49 Z TheOpChicken Kitchen (BOI19_kitchen) C++17
0 / 100
153 ms 260768 KB
#include <iostream>
using namespace std;

const int maxN = 5e2 + 5;

int barr[maxN], dp[maxN][maxN*maxN]; 

int main(){
	cout << maxN << endl;
	int n, m, k;
	cin >> n >> m >> k;

	int total = 0;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		
		if (a < k){
			cout << "Impossible" << endl;
			return 0;
		}
		total += a;
	}

	for (int i = 0; i < m; i++) cin >> barr[i];

	for (int i = barr[0]; i < maxN*maxN; i++) dp[0][i] = min(n, barr[0]);

	for (int i = 1; i < m; i++){
		for (int j = 0; j < maxN*maxN; j++){
			dp[i][j] = dp[i-1][j];
			if (barr[i] <= j){
				dp[i][j] = max(dp[i][j], dp[i-1][j-barr[i]] + min(n, barr[i]));
			}
		}
	}

	bool pos = 0;
	int ans;
	for (int i = total; i < maxN*maxN; i++){
		if (dp[m-1][i] >= n*k){
			pos = 1;
			ans = i;
			break;
		}
	}

	if (!pos) cout << "Impossible" << endl;
	else cout << ans-total << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 260768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 40212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -