답안 #899526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899526 2024-01-06T11:30:34 Z dsyz Kitchen (BOI19_kitchen) C++17
21 / 100
1000 ms 71132 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (3005)
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 39 ms 71004 KB Output is correct
2 Incorrect 43 ms 70904 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 71004 KB Output is correct
2 Incorrect 43 ms 70904 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1043 ms 71076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 340 ms 71128 KB Output is correct
2 Correct 341 ms 70992 KB Output is correct
3 Correct 346 ms 71132 KB Output is correct
4 Correct 342 ms 71128 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 71004 KB Output is correct
2 Incorrect 43 ms 70904 KB Output isn't correct
3 Halted 0 ms 0 KB -