Submission #938641

# Submission time Handle Problem Language Result Execution time Memory
938641 2024-03-05T11:36:35 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
50 ms 4692 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> a(n),b(m);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    int sum = 0LL;
    for (int i = 0; i < m; i++)
        sum+=b[i];
    vector<vector<bool>> dp(m,vector<bool>(sum+1));
    dp[0][0] = 1;
    dp[0][b[0]] = 1;
    for (int i = 1; i < m; i++)
        for (int j = b[i]; j <= sum; j++)
            dp[i][j] = (dp[i-1][j-b[i]] | dp[i-1][j]);
    int oth = 0;
    for (int i = 0; i < n; i++)
        oth+=a[i];
    for (int i = oth; i <= sum; i++)
        if (dp[n-1][i])
        {
            cout << i << '\n';
            return 0;
        }
    cout << "Impossible\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 4692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -