Submission #444803

# Submission time Handle Problem Language Result Execution time Memory
444803 2021-07-15T11:35:21 Z zxcvbnm Kitchen (BOI19_kitchen) C++14
100 / 100
81 ms 1056 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
const int maxN = 305;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for(int& i : a) {
        cin >> i;
    }
    for(int& i : b) {
        cin >> i;
    }

    int ans = INF;
    for(int i : a) {
        if (i < k) {
            cout << "Impossible\n";
            exit(0);
        }
    }

    int time = accumulate(a.begin(), a.end(), 0);

    vector<int> last(maxN*maxN, -INF);
    last[0] = 0;
    vector<int> curr(maxN*maxN, -INF);
    for(int i = 1; i <= m; i++) {
        for(int j = 0; j < maxN*maxN; j++) {
            curr[j] = last[j];
            if (j-b[i-1] < 0) continue;

            curr[j] = max(curr[j], last[j-b[i-1]] + min(n, b[i-1]));
            if (curr[j] >= k*n && j >= time && j-time < ans) {
                ans = j-time;
            }
        }
        last = curr;
    }

    if (ans == INF) {
        cout << "Impossible\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 5 ms 972 KB Output is correct
10 Correct 6 ms 1052 KB Output is correct
11 Correct 6 ms 972 KB Output is correct
12 Correct 5 ms 972 KB Output is correct
13 Correct 5 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1044 KB Output is correct
2 Correct 62 ms 972 KB Output is correct
3 Correct 81 ms 972 KB Output is correct
4 Correct 81 ms 1032 KB Output is correct
5 Correct 79 ms 972 KB Output is correct
6 Correct 58 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 972 KB Output is correct
2 Correct 11 ms 1052 KB Output is correct
3 Correct 11 ms 1056 KB Output is correct
4 Correct 12 ms 1052 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 5 ms 972 KB Output is correct
10 Correct 6 ms 1052 KB Output is correct
11 Correct 6 ms 972 KB Output is correct
12 Correct 5 ms 972 KB Output is correct
13 Correct 5 ms 972 KB Output is correct
14 Correct 71 ms 1044 KB Output is correct
15 Correct 62 ms 972 KB Output is correct
16 Correct 81 ms 972 KB Output is correct
17 Correct 81 ms 1032 KB Output is correct
18 Correct 79 ms 972 KB Output is correct
19 Correct 58 ms 972 KB Output is correct
20 Correct 14 ms 972 KB Output is correct
21 Correct 11 ms 1052 KB Output is correct
22 Correct 11 ms 1056 KB Output is correct
23 Correct 12 ms 1052 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 56 ms 1032 KB Output is correct
26 Correct 66 ms 1036 KB Output is correct
27 Correct 44 ms 972 KB Output is correct
28 Correct 64 ms 972 KB Output is correct
29 Correct 65 ms 972 KB Output is correct
30 Correct 80 ms 1036 KB Output is correct