# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320915 | kimbj0709 | Kitchen (BOI19_kitchen) | C++14 | 100 ms | 1152 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 int long long
#define maxn 90050
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,m,k;
cin >> n >> m >> k;
vector<int> vect1,vect2;
int input;
int s = 0;
for(int i=0;i<n;i++){
cin >> input;
if(input<k){
cout << "Impossible";
return 0;
}
s += input;
}
for(int i=0;i<m;i++){
cin >> input;
vect1.push_back(input);
}
vector<int> dp(maxn,INT_MIN);
dp[0] = 0;
for(int i=0;i<m;i++){
int curradd = min(n,vect1[i]);
for(int j=maxn-1-vect1[i];j>=0;j--){
dp[j+vect1[i]] = max(dp[j+vect1[i]],dp[j]+curradd);
}
}
int ans = INT_MAX;
for(int i=s;i<dp.size();i++){
if(dp[i]>=n*k){
cout << i-s;
return 0;
}
}
cout << "Impossible";
}
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... |