답안 #428266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428266 2021-06-15T09:19:26 Z schse Kitchen (BOI19_kitchen) C++17
0 / 100
19 ms 296 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&&min(chefs[0], chefs[1]) < N))
        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 1 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 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -