Submission #529360

# Submission time Handle Problem Language Result Execution time Memory
529360 2022-02-22T21:24:48 Z OttoTheDino Kitchen (BOI19_kitchen) C++17
21 / 100
21 ms 716 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;

const int mx = 1e5;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, k; cin >> n >> m >> k;
    int a[n], b[m], s = 0;
    rep (i,0,n-1) {
        cin >> a[i];
        if (a[i]<k) {
            cout << "Impossible\n";
            return 0;
        }
        s += a[i];
    }
    rep (i,0,m-1) cin >> b[i];

    int dp[mx+1] = {}; //for some certain sum, what is the maximum number of different (chef, meal) pairs, if it is at least n*k and the sum is also more than the sum of ai (s), then we should have found an answer, lets see what is the minimum
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;

    rep (i,0,m-1)
        rrep (j,mx,b[i])
            dp[j] = max(dp[j], dp[j-b[i]] + min(b[i], n));

    rep (i,s,mx) {
        if (dp[i]>=n*k) {
            cout << i-s << "\n";
            return 0;
        }
    } 

    cout << "Impossible\n";

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 696 KB Output is correct
7 Correct 1 ms 692 KB Output is correct
8 Incorrect 1 ms 588 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 696 KB Output is correct
7 Correct 1 ms 692 KB Output is correct
8 Incorrect 1 ms 588 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 700 KB Output is correct
2 Correct 4 ms 696 KB Output is correct
3 Correct 3 ms 588 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 0 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 696 KB Output is correct
7 Correct 1 ms 692 KB Output is correct
8 Incorrect 1 ms 588 KB Output isn't correct
9 Halted 0 ms 0 KB -