Submission #899532

# Submission time Handle Problem Language Result Execution time Memory
899532 2024-01-06T11:41:43 Z dsyz Kitchen (BOI19_kitchen) C++17
100 / 100
24 ms 1368 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;
	}
	for(ll i = 0;i < MAXN * MAXN;i++){
		dp[i] = -1e18;
	}
	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';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1368 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1368 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 2 ms 1196 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1188 KB Output is correct
2 Correct 16 ms 1116 KB Output is correct
3 Correct 22 ms 1196 KB Output is correct
4 Correct 21 ms 1116 KB Output is correct
5 Correct 21 ms 1200 KB Output is correct
6 Correct 15 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1368 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 2 ms 1196 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 19 ms 1188 KB Output is correct
15 Correct 16 ms 1116 KB Output is correct
16 Correct 22 ms 1196 KB Output is correct
17 Correct 21 ms 1116 KB Output is correct
18 Correct 21 ms 1200 KB Output is correct
19 Correct 15 ms 1112 KB Output is correct
20 Correct 3 ms 1116 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 3 ms 1116 KB Output is correct
23 Correct 3 ms 1116 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 16 ms 1112 KB Output is correct
26 Correct 17 ms 1116 KB Output is correct
27 Correct 12 ms 1116 KB Output is correct
28 Correct 21 ms 1192 KB Output is correct
29 Correct 18 ms 1112 KB Output is correct
30 Correct 24 ms 1116 KB Output is correct