Submission #915728

# Submission time Handle Problem Language Result Execution time Memory
915728 2024-01-24T15:51:44 Z RaulAndrei01 Kitchen (BOI19_kitchen) C++14
0 / 100
13 ms 664 KB
#include<iostream>
#include<vector>

using namespace std;
const int NMAX = 300;
const int INF = 1e9 + 4;
int a[NMAX+1] , b[NMAX+1];

int dp[NMAX*NMAX+1]; // dp[sum] = cate ore max sunt eligibile pt n*k

int main ()
{
    int n, m, k;
    cin >> n >> m >> k;

    int sumA = 0;
    bool bad = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sumA += a[i];
        if (a[i] < k) bad = 1;
    }
    
    int sumB = 0;
    for (int i = 1; i <= m; i++)
    {
        cin >> b[i];
        sumB += b[i];
    }

    if (bad) {
        cout << "IMPOSSIBLE\n";
        return 0;
    }

    for (int i = 1; i <= sumA; i++)
    {
        dp[i] = -INF;
    }
    
    dp[0] = 0;

    for (int i = 1; i <= m; i++)
    {
        for (int sum = sumB; sum >= b[i]; sum--)
        {
            int addToNK = min(b[i] , n);
            dp[sum] = max(dp[sum] , dp[sum-b[i]] + addToNK);
        }
    }

    int ans = 0;
    for (int i = sumA; i <= sumB; i++)
    {
        
        if (dp[i] >= n*k)
        {
            ans = i - sumA;
            break;
        }
    }
    if (ans)
        cout << ans << '\n';
    else cout << "IMPOSSIBLE\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 604 KB Output is correct
2 Correct 10 ms 664 KB Output is correct
3 Incorrect 12 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -