답안 #428267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428267 2021-06-15T09:20:30 Z schse Kitchen (BOI19_kitchen) C++17
20 / 100
46 ms 292 KB
#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;
}

Compilation message

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())
      |                                ~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 288 KB Output is correct
2 Correct 18 ms 292 KB Output is correct
3 Correct 27 ms 204 KB Output is correct
4 Correct 44 ms 204 KB Output is correct
5 Correct 46 ms 292 KB Output is correct
6 Correct 16 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -