답안 #858314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858314 2023-10-08T05:49:39 Z Trisanu_Das Kitchen (BOI19_kitchen) C++17
21 / 100
38 ms 111456 KB
#include <bits/stdc++.h>
using namespace std;
 
int barr[305], dp[305][305 * 305]; 
 
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\n";
			return 0;
		}
		total += a;
	}
	for (int i = 0; i < m; i++) cin >> barr[i];
	memset(dp, INT_MIN, sizeof(dp));
	dp[0][barr[0]] = min(n, barr[0]);
	for (int i = 1; i < m; i++){
		for (int j = 0; j < 305 * 305; 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 < 305 * 305; i++){
		if (dp[m-1][i] >= n * k){
			pos = 1;
			ans = i;
			break;
		}
	}
 
	if (!pos) cout << "Impossible\n";
	else cout << ans - total << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 111448 KB Output is correct
2 Correct 12 ms 111452 KB Output is correct
3 Incorrect 12 ms 111448 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 111448 KB Output is correct
2 Correct 12 ms 111452 KB Output is correct
3 Incorrect 12 ms 111448 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 111456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 111448 KB Output is correct
2 Correct 17 ms 111280 KB Output is correct
3 Correct 16 ms 111452 KB Output is correct
4 Correct 16 ms 111452 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 111448 KB Output is correct
2 Correct 12 ms 111452 KB Output is correct
3 Incorrect 12 ms 111448 KB Output isn't correct
4 Halted 0 ms 0 KB -