# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719580 | jamezzz | Kitchen (BOI19_kitchen) | C++17 | 291 ms | 111436 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define INF 1023456789
#define maxn 305
int n,m,k,a[maxn],b[maxn],memo[maxn][maxn*maxn+5];
int dp(int i,int num){
if(num<0)return -INF;
if(i==-1&&num==0)return 0;
if(i==-1&&num!=0)return -INF;
if(memo[i][num]!=-1)return memo[i][num];
return memo[i][num]=max(dp(i-1,num),dp(i-1,num-b[i])+min(n,b[i]));
}
int main(){
sf("%d%d%d",&n,&m,&k);
int sm=0;
for(int i=0;i<n;++i){
sf("%d",&a[i]);
if(a[i]<k){
printf("Impossible\n");
exit(0);
}
sm+=a[i];
}
int sm2=0;
for(int i=0;i<m;++i){
sf("%d",&b[i]);
sm2+=b[i];
}
memset(memo,-1,sizeof memo);
for(int i=sm;i<=sm2;++i){
if(dp(m-1,i)>=n*k){
printf("%d\n",i-sm);
exit(0);
}
}
printf("Impossible\n");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |