Submission #714555

# Submission time Handle Problem Language Result Execution time Memory
714555 2023-03-25T05:05:55 Z amirhoseinfar1385 Kitchen (BOI19_kitchen) C++17
52 / 100
1000 ms 71312 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=3000+10;
int dp[maxn*maxn],fake[maxn*maxn],inf=1e9+5;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	for(int i=0;i<maxn*maxn;i++){
		dp[i]=-inf;
	}
	int n,m,k;
	cin>>n>>m>>k;
	vector<int>alln(n),allm(m);
	int f=0;
	int sumn=0;
	for(int i=0;i<n;i++){
		cin>>alln[i];
		if(alln[i]<k){
			f=1;
		}
		sumn+=alln[i];
	}
	int summ=0,mainsumm=0;
	for(int i=0;i<m;i++){
		cin>>allm[i];
		summ+=min(allm[i],n);
		mainsumm+=allm[i];
	}
	if(f==1||summ<n*k||mainsumm<sumn){
		cout<<"Impossible\n";
		return 0;
	}
	int res=inf;
	dp[0]=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<maxn*maxn;j++){
			fake[j]=dp[j];
			dp[j]=-inf;
		}
		for(int j=0;j<maxn*maxn;j++){
			if(j<allm[i]){
				dp[j]=fake[j];
				continue;
			}
			dp[j]=max(fake[j],fake[j-allm[i]]+min(n,allm[i]));
		}
	}
	//cout<<dp[4]<<" "<<dp[7]<<" "<<dp[3]<<"\n";
	for(int i=0;i<maxn*maxn;i++){
		if(i>=sumn&&dp[i]>=n*k){
			res=min(res,i-sumn);
		}
	}
	cout<<res<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 77 ms 71216 KB Output is correct
2 Correct 75 ms 71124 KB Output is correct
3 Correct 76 ms 71112 KB Output is correct
4 Correct 79 ms 71224 KB Output is correct
5 Correct 77 ms 71220 KB Output is correct
6 Correct 16 ms 35720 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 15 ms 35668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 71216 KB Output is correct
2 Correct 75 ms 71124 KB Output is correct
3 Correct 76 ms 71112 KB Output is correct
4 Correct 79 ms 71224 KB Output is correct
5 Correct 77 ms 71220 KB Output is correct
6 Correct 16 ms 35720 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 15 ms 35668 KB Output is correct
9 Correct 350 ms 71180 KB Output is correct
10 Correct 353 ms 71272 KB Output is correct
11 Correct 18 ms 35668 KB Output is correct
12 Correct 368 ms 71116 KB Output is correct
13 Correct 374 ms 71216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 71192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 899 ms 71220 KB Output is correct
2 Correct 871 ms 71224 KB Output is correct
3 Correct 887 ms 71312 KB Output is correct
4 Correct 880 ms 71228 KB Output is correct
5 Correct 15 ms 35788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 71216 KB Output is correct
2 Correct 75 ms 71124 KB Output is correct
3 Correct 76 ms 71112 KB Output is correct
4 Correct 79 ms 71224 KB Output is correct
5 Correct 77 ms 71220 KB Output is correct
6 Correct 16 ms 35720 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 15 ms 35668 KB Output is correct
9 Correct 350 ms 71180 KB Output is correct
10 Correct 353 ms 71272 KB Output is correct
11 Correct 18 ms 35668 KB Output is correct
12 Correct 368 ms 71116 KB Output is correct
13 Correct 374 ms 71216 KB Output is correct
14 Execution timed out 1075 ms 71192 KB Time limit exceeded
15 Halted 0 ms 0 KB -