Submission #428264

#TimeUsernameProblemLanguageResultExecution timeMemory
428264schseKitchen (BOI19_kitchen)C++17
0 / 100
2 ms460 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...