답안 #899522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899522 2024-01-06T11:27:28 Z dsyz Kitchen (BOI19_kitchen) C++17
21 / 100
21 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (305)
ll N,M,K,totalA;
ll A[MAXN], B[MAXN];
ll dp[MAXN * MAXN];
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>N>>M>>K;
	bool ok = 1;
	for(ll i = 0;i < N;i++){ //number of dishes
		cin>>A[i];
		totalA += A[i];
		if(A[i] < K) ok = 0;
	}
	for(ll i = 0;i < M;i++){ //number of chefs
		cin>>B[i];
	}
	if(!ok){
		cout<<"Impossible"<<'\n';
		return 0;
	}
	dp[0] = 0;
	for(ll i = 0;i < M;i++){
		for(ll j = MAXN * MAXN - 1;j >= B[i];j--){
			dp[j] = max(dp[j],dp[j - B[i]] + min(B[i],N));
		}
	}
	ll minimum = 1e18;
	for(ll i = totalA;i < MAXN * MAXN;i++){
		if(dp[i] >= N * K){
			minimum = i;
			break;
		}
	}
	if(minimum == 1e18) cout<<"Impossible"<<'\n';
	else cout<<minimum - totalA<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 980 KB Output is correct
2 Correct 3 ms 1112 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 4 ms 1116 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -