# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428266 | schse | Kitchen (BOI19_kitchen) | C++17 | 19 ms | 296 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;
int main()
{
int N, M, K;
cin >> N >> M >> K;
vector<int> recipes(N), chefs(M);
for (int &i : recipes)
cin >> i;
for (int &i : chefs)
cin >> i;
int totalwork = accumulate(recipes.begin(), recipes.end(), 0);
int mnovertme = INT32_MAX;
vector<bool> workable(totalwork);
workable[0] = true;
for (int chef : chefs)
{
for (int i = workable.size() - 1; i >= 0; i--)
{
if (workable[i] && i + chef < workable.size())
workable[i + chef] = true;
else if (workable[i])
mnovertme = min(mnovertme, i + chef - totalwork);
}
}
if (mnovertme == INT32_MAX || (M>1&&min(chefs[0], chefs[1]) < N))
cout << "Impossible\n";
else
cout << mnovertme;
}
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... |