Submission #745814

# Submission time Handle Problem Language Result Execution time Memory
745814 2023-05-21T08:11:58 Z vjudge1 Kitchen (BOI19_kitchen) C++11
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

int n,m,k;
int a[301];
int b[301];
int sum=0;

void subtask1() {
    int ans=1e9;
    if (k==1) {
        for (int i=1;i<=m;i++) {
            if (b[i]>=sum) {
                ans=min(ans,b[i]-sum);
            }
        }
        int u=0;
        for (int i=1;i<=m;i++) {
            u+=b[i];
        }
        if (u>=sum) {
            ans=min(ans,u);
        }
        if (ans==1e9) {
            cout << "Impossible" << endl;
        } else {
            cout << ans-sum << endl;
        }
        return;
    } else if (k==2) {
        int u=0;
        for (int i=1;i<=m;i++) {
            u+=b[i];
        }
        if (u>=sum) {
            ans=min(ans,u);
        }
        if (ans==1e9) {
            cout << "Impossible" << endl;
        } else {
            cout << ans-sum << endl;
        }
        return;
    } else {
        cout << "Impossible" << endl;
        return;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    for (int i=1;i<=n;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    for (int i=1;i<=m;i++) {
        cin >> b[i];
    }
    if (m<=2) {
        subtask1();
        return(0);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -