제출 #428267

#제출 시각아이디문제언어결과실행 시간메모리
428267schseKitchen (BOI19_kitchen)C++17
20 / 100
46 ms292 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 mnovertme = INT32_MAX;
    vector<bool> workable(totalwork);
    workable[0] = true;
    for (int chef : chefs)
    {
        for (int i = workable.size() - 1; i >= 0; i--)
        {
            if (workable[i] && i + chef < workable.size())
                workable[i + chef] = true;
            else if (workable[i])
                mnovertme = min(mnovertme, i + chef - totalwork);
        }
    }
    if (mnovertme == INT32_MAX || (M > 1 && K > 1 && min(chefs[0], chefs[1]) < N) || K > M)
        cout << "Impossible\n";
    else
        cout << mnovertme;
}

컴파일 시 표준 에러 (stderr) 메시지

kitchen.cpp: In function 'int main()':
kitchen.cpp:22:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if (workable[i] && i + chef < workable.size())
      |                                ~~~~~~~~~^~~~~~~~~~~~~~~~~
#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...