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 totalchefs = accumulate(chefs.begin(), chefs.end(), 0);
if (K > M || totalchefs < totalwork)
cout << "Impossible\n";
else if (M == 1 && K == 1)
cout << chefs[0] - totalwork;
else if (M == 2 && K == 1)
{
if (min(chefs[0], chefs[1]) >= totalwork)
cout << min(chefs[0], chefs[1]) - totalwork;
else if (max(chefs[0], chefs[1]) >= totalwork)
cout << max(chefs[0], chefs[1]) - totalwork;
else
cout << chefs[0]+chefs[1] - totalwork;
}
else if (M == 2 && K == 2)
{
if (min(chefs[0], chefs[1]) < N)
cout << "Impossible\n";
else
cout << chefs[0]+chefs[1] - totalwork;
}
else
assert(false);
}
# | 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... |