Submission #745874

# Submission time Handle Problem Language Result Execution time Memory
745874 2023-05-21T09:03:36 Z vjudge1 Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int>a(n), b(m);
    int sum = 0, sum2 = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
        sum2 += b[i];
    }
    if(sum2 < sum || m < k){
        cout << "Impossible\n";
        return 0;
    }
    if(k >= 2){
        if(min(b[0], b[1]) < n){
            cout << "Impossible\n";
            return 0;
        }
    }
    if(m == 1){
        cout << sum2 - sum << endl;
        return 0;
    }
    if(min(b[0], b[1]) >= sum){
        cout << min(b[0], b[1]) - sum << endl;
        return 0;
    }
    if(max(b[0], b[1]) >= sum){
        cout << max(b[0], b[1]) - sum << endl;
        return 0;
    }
    cout << b[0] + b[1] - sum << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -