Submission #1004577

# Submission time Handle Problem Language Result Execution time Memory
1004577 2024-06-21T09:59:52 Z vjudge1 Kitchen (BOI19_kitchen) C++17
100 / 100
29 ms 1112 KB
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
#define OPT         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define intt        long long
#define ll          long long
#define pb          push_back
#define arr         array
#define vll         vector<int>
#define fi          first
#define se          second
#define rep(i,j,k)  for(int i = j; i <= k; ++i)
#define all(a)      a.begin(),a.end()
#define pii         pair<int,int>
#define endll       '\n'
using namespace std;
const ll INF = 1e18;
const int N = 305 * 305;
 
ll n, m, k, sum, chefsum;
ll a[N], chef[N];
ll dp[N];
signed main()
{
    cin >> n >> m >> k;
    for(ll i = 1; i <= n; ++i)
        cin >> a[i], sum += a[i];
    sort(a + 1, a + n + 1);
    for(ll i = 1; i <= m; ++i)
        cin >> chef[i];
    sort(chef + 1, chef + 1 + m);
    if(m < k || a[1] < k) 
    {
        cout << "Impossible" << endll;
        return 0;
    }
    for (ll i = 1; i <= m; ++i) {
        for (int j = N; j >= chef[i]; --j) {
            if (j == chef[i] || dp[j - chef[i]]) {
                dp[j] =  max(dp[j], dp[j - chef[i]] + min(chef[i], n));
            }
        }
    }
    for(ll i = sum; i <= N; ++i)
    {
        if(dp[i] >= n * k)
        {
            cout << i - sum << endll;
            return 0;
        }
    }
    cout << "Impossible" << endll;
}
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 860 KB Output is correct
2 Correct 15 ms 856 KB Output is correct
3 Correct 19 ms 604 KB Output is correct
4 Correct 29 ms 856 KB Output is correct
5 Correct 20 ms 1112 KB Output is correct
6 Correct 13 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 484 KB Output is correct
14 Correct 17 ms 860 KB Output is correct
15 Correct 15 ms 856 KB Output is correct
16 Correct 19 ms 604 KB Output is correct
17 Correct 29 ms 856 KB Output is correct
18 Correct 20 ms 1112 KB Output is correct
19 Correct 13 ms 604 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 13 ms 860 KB Output is correct
26 Correct 22 ms 1024 KB Output is correct
27 Correct 10 ms 600 KB Output is correct
28 Correct 17 ms 860 KB Output is correct
29 Correct 16 ms 968 KB Output is correct
30 Correct 19 ms 860 KB Output is correct