Submission #146470

# Submission time Handle Problem Language Result Execution time Memory
146470 2019-08-24T08:39:27 Z Alexa2001 Kitchen (BOI19_kitchen) C++17
100 / 100
28 ms 760 KB
#include <bits/stdc++.h>

using namespace std;

const int lim = 300;

int dp[lim * lim + 10];
int n, m, k;
int A[lim+2], B[lim+2];


void add(int cost, int ben)
{
    int i;
    for(i=m*lim - cost; i>=0; --i)
        dp[i+cost] = max(dp[i+cost], dp[i] + ben);
}

int main()
{
  //  freopen("kitchen2.in", "r", stdin);
    cin.tie(0); cin.sync_with_stdio(false);

    cin >> n >> m >> k;
    
    int i, sum = 0;
    
    for(i=1; i<=n; ++i) cin >> A[i], sum += A[i];
    for(i=1; i<=m; ++i) cin >> B[i];
    
    for(i=1; i<=m*lim; ++i) dp[i] = -1e9;

    for(i=1; i<=m; ++i)
        add(B[i], min(n, B[i]));
    
    for(i=1; i<=n; ++i)
        if(A[i] < k) 
        {
            cout << "Impossible\n";
            return 0;
        }

    for(i=sum; i <= m*lim; ++i)
        if(dp[i] >= k * n)
        {
            cout << i - sum << '\n';
            return 0;
        }
    cout << "Impossible\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 632 KB Output is correct
2 Correct 17 ms 636 KB Output is correct
3 Correct 28 ms 760 KB Output is correct
4 Correct 28 ms 760 KB Output is correct
5 Correct 26 ms 632 KB Output is correct
6 Correct 15 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 420 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 22 ms 632 KB Output is correct
15 Correct 17 ms 636 KB Output is correct
16 Correct 28 ms 760 KB Output is correct
17 Correct 28 ms 760 KB Output is correct
18 Correct 26 ms 632 KB Output is correct
19 Correct 15 ms 632 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 420 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 15 ms 760 KB Output is correct
26 Correct 19 ms 636 KB Output is correct
27 Correct 10 ms 504 KB Output is correct
28 Correct 19 ms 636 KB Output is correct
29 Correct 20 ms 760 KB Output is correct
30 Correct 28 ms 632 KB Output is correct