Submission #602825

# Submission time Handle Problem Language Result Execution time Memory
602825 2022-07-23T11:39:39 Z WongChun1234 Kitchen (BOI19_kitchen) C++14
100 / 100
101 ms 118160 KB
#include<bits/stdc++.h>
using namespace std;
const int N=350,M=100050;
int n,m,k,a[N],b[N],dp[N][M],sum;
int main(){
	cin>>n>>m>>k;
	for (int i=1;i<=n;i++) {
		cin>>a[i];
		if (a[i]<k){
			cout<<"Impossible\n";
			return 0;
		}
		sum+=a[i];
	}
	for (int i=1;i<=m;i++) cin>>b[i];
	for (int i=0;i<=m;i++) for (int j=0;j<M;j++) dp[i][j]=INT_MIN;
	dp[0][0]=0;
	for (int i=1;i<=m;i++) for (int j=0;j<M;j++){
		if (j<b[i]) dp[i][j]=dp[i-1][j];
		else if (b[i]>n) dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i]]+n);
		else dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i]]+b[i]);
	}
	for (int j=sum;j<M;j++){
		if (dp[m][j]>=n*k){
			cout<<j-sum<<"\n";
			return 0;
		}
	}
	cout<<"Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 1460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 1460 KB Output is correct
9 Correct 6 ms 6580 KB Output is correct
10 Correct 5 ms 6484 KB Output is correct
11 Correct 8 ms 6504 KB Output is correct
12 Correct 6 ms 6484 KB Output is correct
13 Correct 5 ms 6484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 102860 KB Output is correct
2 Correct 71 ms 89264 KB Output is correct
3 Correct 93 ms 118096 KB Output is correct
4 Correct 91 ms 118160 KB Output is correct
5 Correct 90 ms 114188 KB Output is correct
6 Correct 77 ms 82032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 16352 KB Output is correct
2 Correct 14 ms 16308 KB Output is correct
3 Correct 14 ms 16284 KB Output is correct
4 Correct 16 ms 16364 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 1460 KB Output is correct
9 Correct 6 ms 6580 KB Output is correct
10 Correct 5 ms 6484 KB Output is correct
11 Correct 8 ms 6504 KB Output is correct
12 Correct 6 ms 6484 KB Output is correct
13 Correct 5 ms 6484 KB Output is correct
14 Correct 85 ms 102860 KB Output is correct
15 Correct 71 ms 89264 KB Output is correct
16 Correct 93 ms 118096 KB Output is correct
17 Correct 91 ms 118160 KB Output is correct
18 Correct 90 ms 114188 KB Output is correct
19 Correct 77 ms 82032 KB Output is correct
20 Correct 15 ms 16352 KB Output is correct
21 Correct 14 ms 16308 KB Output is correct
22 Correct 14 ms 16284 KB Output is correct
23 Correct 16 ms 16364 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 69 ms 82804 KB Output is correct
26 Correct 76 ms 95832 KB Output is correct
27 Correct 56 ms 63252 KB Output is correct
28 Correct 94 ms 96132 KB Output is correct
29 Correct 81 ms 98592 KB Output is correct
30 Correct 101 ms 118160 KB Output is correct