Submission #915759

# Submission time Handle Problem Language Result Execution time Memory
915759 2024-01-24T16:25:38 Z RaulAndrei01 Kitchen (BOI19_kitchen) C++17
0 / 100
99 ms 78576 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][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 || sumB < sumA) {
        cout << "Impossible\n";
        return 0;
    }
 
    for (int i = 0; i <= max(sumA , sumB); i++)
    {
        for (int j = 0; j <= m; j++)
            dp[i][j] = -INF;
    }
    
    dp[0][0] = 0;
 
    for (int sum = 0; sum <= sumB; sum++)
    {
        for (int i = 1; i <= m; i++)
        {
            int addToNK = min(b[i] , n);
            dp[sum+b[i]][i] = max(dp[sum+b[i]][i] , dp[sum][i-1] + addToNK);
        }
    }
 
    int ans = 0;
    for (int i = sumA; i <= sumB; i++)
    {
        
        if (dp[i][m] >= n*k)
        {
            ans = i - sumA;
            break;
        }
    }
    if (ans)
        cout << ans << '\n';
    else cout << "Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 78576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -