답안 #745933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745933 2023-05-21T09:45:38 Z vjudge1 Kitchen (BOI19_kitchen) C++14
9 / 100
71 ms 300 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
    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" << endl;
            return 0;
        }
        requiredHours += x;
    }
    for (int & x : chefs) cin >> x;

    int mo = INT_MAX;
    for (int mask = 1; mask < (1 << m); mask++){
        if (__builtin_popcount(mask) < k) continue;
        
        int orak = 0;
        set<pair<int, int> > tud, tud2;
        for (int i = 0; i < m; i++){
            if ((1 << i) & mask) {
                orak += chefs[i];
                tud.insert(make_pair(chefs[i], i));
            }
        }
        bool jo = true;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < k; j++){
                if (tud.size() == 0){
                    jo = false;
                    break;
                }
                if ((*tud.rbegin()).first != 1){
                    tud2.insert(make_pair((*tud.rbegin()).first - 1, (*tud.rbegin()).second));
                }
                tud.erase(*tud.rbegin());
            }
            if (jo == false) continue;
            while(!tud.empty()){
                tud2.insert(*tud.rbegin());
                tud.erase(*tud.rbegin());
            }
            swap(tud, tud2);
        }
        if (requiredHours <= orak) mo = min(mo, orak - requiredHours);
    }
    if (mo != INT_MAX) cout << mo << endl;
    else cout << "Impossible" << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 31 ms 300 KB Output is correct
10 Correct 71 ms 280 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 31 ms 300 KB Output is correct
10 Correct 71 ms 280 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -