답안 #783886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783886 2023-07-15T11:47:52 Z TheOpChicken Kitchen (BOI19_kitchen) C++17
41 / 100
76 ms 109520 KB
#include <iostream>
using namespace std;

const int maxN = 305, inf = 1e9;

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

int main(){
	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 = 0; i < m; i++){
		for (int j = 0; j < maxN*maxN; j++) dp[i][j] = -inf;
	}
	dp[0][barr[0]] = 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 95308 KB Output is correct
2 Correct 57 ms 82572 KB Output is correct
3 Correct 75 ms 109504 KB Output is correct
4 Correct 76 ms 109520 KB Output is correct
5 Correct 74 ms 105872 KB Output is correct
6 Correct 55 ms 76024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 14932 KB Output is correct
2 Correct 11 ms 14804 KB Output is correct
3 Correct 11 ms 14868 KB Output is correct
4 Correct 11 ms 14804 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -