# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1133769 | ChuanChen | Kitchen (BOI19_kitchen) | C++20 | 18 ms | 584 KiB |
#include<bits/stdc++.h>
using namespace std;
const int lim = 301;
int n, m, k;
int sumA;
int dp[lim*lim];
//dp[c] = maior base possivel com subset de soma c
void solve(){
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
int a; cin >> a;
sumA+=a;
if(a < k){
cout << "Impossible\n";
return;
}
}
for(int i = 1; i < lim*lim; i++) dp[i] = -1;
for(int i = 1; i <= m; i++){
int b; cin >> b;
for(int c = lim*lim-1; c-b >= 0; c--) if(dp[c-b] != -1){
dp[c] = max(dp[c], dp[c-b]+min(b, n));
}
}
for(int c = sumA; c < lim*lim; c++){
if(dp[c] >= n*k){
cout << c-sumA << '\n';
return;
}
}
cout << "Impossible\n";
}
int main(){
cin.tie(0)->sync_with_stdio(0);
clock_t Ostart;
Ostart = clock();
if(fopen("in", "r")){
freopen("in", "r", stdin);
freopen("out", "w", stdout);
freopen("err", "w", stderr);
}
solve();
cerr << fixed << setprecision(4) << "Exec time: "
<< (double)(clock()-Ostart)/CLOCKS_PER_SEC << " secs.\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... |