답안 #917998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917998 2024-01-29T10:38:44 Z borisAngelov Kitchen (BOI19_kitchen) C++17
20 / 100
1 ms 488 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 305;
const int maxsum = maxn * maxn;

int n, m, k;

int a[maxn];
int b[maxn];

bitset<maxsum> dp;

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> m >> k;

    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= m; ++i)
    {
        cin >> b[i];
    }

    dp[0] = true;

    for (int i = 1; i <= m; ++i)
    {
        dp |= (dp << b[i]);
    }

    int target = 0;

    for (int i = 1; i <= n; ++i)
    {
        target += a[i];
    }

    for (int i = target; i < maxsum; ++i)
    {
        if (dp[i] == true)
        {
            cout << i - target << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -