Submission #701263

# Submission time Handle Problem Language Result Execution time Memory
701263 2023-02-20T16:59:43 Z _martynas Kitchen (BOI19_kitchen) C++11
100 / 100
47 ms 1036 KB
#include <bits/stdc++.h>

using namespace std;

const int MXN = 305;

int n, m, k;
int dp[2*MXN*MXN];
int A[MXN], B[MXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < m; i++) cin >> B[i];
    for(int i = 0; i < n; i++) {
        if(A[i] < k) {
            cout << "Impossible\n";
            return 0;
        }
    }
    int sum = accumulate(A, A+n, 0);
    fill(dp, dp+2*MXN*MXN, -1e9);
    dp[0] = 0;
    for(int i = 0; i < m; i++) {
        for(int j = 2*MXN*MXN-1; j >= B[i]; j--) {
            dp[j] = max(dp[j], dp[j-B[i]]+min(B[i], n));
        }
    }
    for(int i = sum; i < 2*MXN*MXN; i++) {
        if(dp[i] >= n*k) {
            cout << i-sum << "\n";
            return 0;
        }
    }
    cout << "Impossible\n";
    return 0;
}

/*



*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 3 ms 980 KB Output is correct
11 Correct 3 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1032 KB Output is correct
2 Correct 37 ms 980 KB Output is correct
3 Correct 47 ms 1036 KB Output is correct
4 Correct 46 ms 980 KB Output is correct
5 Correct 43 ms 980 KB Output is correct
6 Correct 31 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 980 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 7 ms 964 KB Output is correct
4 Correct 7 ms 980 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 3 ms 980 KB Output is correct
11 Correct 3 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 47 ms 1032 KB Output is correct
15 Correct 37 ms 980 KB Output is correct
16 Correct 47 ms 1036 KB Output is correct
17 Correct 46 ms 980 KB Output is correct
18 Correct 43 ms 980 KB Output is correct
19 Correct 31 ms 1032 KB Output is correct
20 Correct 6 ms 980 KB Output is correct
21 Correct 6 ms 980 KB Output is correct
22 Correct 7 ms 964 KB Output is correct
23 Correct 7 ms 980 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 40 ms 1032 KB Output is correct
26 Correct 47 ms 980 KB Output is correct
27 Correct 25 ms 980 KB Output is correct
28 Correct 37 ms 980 KB Output is correct
29 Correct 38 ms 1028 KB Output is correct
30 Correct 45 ms 980 KB Output is correct