# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139925 | ae04071 | Kitchen (BOI19_kitchen) | C++11 | 29 ms | 760 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;
const int INF = 1e8;
int n,m,K,a[300],b[300];
int dp[90001];
int main() {
scanf("%d%d%d",&n,&m,&K);
for(int i=0;i<n;i++) scanf("%d",a+i);
for(int i=0;i<m;i++) scanf("%d",b+i);
int as=0;
for(int i=0;i<n;i++) {
if(a[i]<K) {
puts("Impossible");
return 0;
}as+=a[i];
}
for(int i=1;i<=90000;i++) dp[i] = -INF;
for(int i=0;i<m;i++) {
for(int j=90000-b[i];j>=0;j--) dp[j+b[i]] = max(dp[j+b[i]], dp[j] + min(n,b[i]));
}
for(int i=as;i<=90000;i++) if(dp[i] >= n*K) {
printf("%d\n",i - as);
return 0;
}
puts("Impossible");
return 0;
}
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... |