# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724015 | lovrot | Kitchen (BOI19_kitchen) | C++17 | 34 ms | 1012 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 <cstdio>
#include <algorithm>
using namespace std;
const int N = 310;
const int INF = 2e9;
int n, m, k, A[N], B[N];
int dp[2][N * N];
int main() {
scanf("%d%d%d", &n, &m, &k);
int nim = INF, sum = 0;
for(int i = 0; i < n; i++) {
scanf("%d", A + i);
nim = min(nim, A[i]);
sum += A[i];
}
for(int i = 0; i < m; i++) scanf("%d", B + i);
if(nim < k || m < k) {
printf("Impossible\n");
return 0;
}
bool f = 0;
for(int i = 0; i < m; i++) {
f ^= 1;
for(int j = 0; j < N * N; j++)
dp[f][j] = max(dp[!f][j], B[i] > j ? 0 : dp[!f][j - B[i]] + min(n, B[i]));
}
for(int i = 0; i < N * N; i++)
if(dp[f][i] >= n * k && i >= sum) {
printf("%d\n", i - sum);
return 0;
}
printf("Impossible\n");
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... |