# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161846 | karma | Kitchen (BOI19_kitchen) | C++14 | 240 ms | 113784 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>
#define pb emplace_back
#define ll long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N = 307;
const int Sum = N * N;
int f[Sum][N], s, a[N], b[N], sum, n, m, k;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define Task "test"
if(fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n >> m >> k;
for(int i = 1; i <= n; ++i) {
cin >> a[i], s += a[i];
if(a[i] < k) return cout << "Impossible", 0;
}
for(int j = 1; j <= m; ++j) cin >> b[j], sum += b[j];
memset(&f, -1, sizeof f);
for(int i = 0; i <= m; ++i) f[0][i] = 0;
for(int i = 1; i <= sum; ++i) {
for(int j = 1; j <= m; ++j) {
if(i - b[j] >= 0 && f[i - b[j]][j - 1] != -1)
f[i][j] = f[i - b[j]][j - 1] + min(n, b[j]);
}
for(int j = 1; j <= m; ++j) f[i][j] = max(f[i][j - 1], f[i][j]);
}
for(int i = s; i <= sum; ++i) {
if(f[i][m] >= k * n) return cout << i - s, 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... |