Submission #746064

# Submission time Handle Problem Language Result Execution time Memory
746064 2023-05-21T10:59:05 Z vjudge1 Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>

using namespace std;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m, k, requiredHours = 0;
    cin >> n >> m >> k;
    
    vector<int> meals(n), chefs(m);

    for (int & x : meals) {
        cin >> x;
        if (x < k){
            cout << "Impossible" << '\n';
            return 0;
        }
        requiredHours += x;
    }
    long long allH = 0;
    for (int & x : chefs) {
        cin >> x;
        allH += x;
    }
    if (allH < requiredHours) {
        cout << "Impossible" << endl;
        return 0;
    }

    int mo = INT_MAX;
    for (int mask = 1; mask < (1 << m); mask++){
        if (__builtin_popcount(mask) < k) continue;
        
        int orak = 0;
        int van = 0;
        for (int i = 0; i < m; i++){
            if ((1 << i) & mask) {
                orak += chefs[i];
                van += min(chefs[i], k);
            }
        }
        if (orak < requiredHours) continue;
        if (van < k * n) continue;
        
        mo = min(mo, orak - requiredHours);
    }
    if (mo != INT_MAX) cout << mo << '\n';
    else cout << "Impossible" << '\n';

    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 1 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 -