답안 #1033256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033256 2024-07-24T15:17:30 Z phoenix Kitchen (BOI19_kitchen) C++17
72 / 100
1000 ms 50008 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 333;

int n, m, k;

int A[N];
int B[N];


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];
    
    if (*min_element(A, A + n) < k) {
        cout << "Impossible\n";
        return 0;
    }

    sort(B, B + m);

    int sum = 0;
    for (int i = 0; i < m; i++) sum += B[i];

    vector<vector<int>> dp(sum + 1, vector<int>(k + 1, 0));
    vector<bool> us(sum + 1);
    us[0] = true;
    dp[0][0] = 1e9;
    for (int i = 0; i < m; i++) {
        for (int s = sum; s >= B[i]; s--) {
            us[s] = (us[s] | us[s - B[i]]);
            if (!us[s - B[i]]) continue;
            dp[s][1] = s;
            for (int j = 2; j <= k; j++) {
                dp[s][j] = max(dp[s][j], min(s / j, dp[s - B[i]][j - 1]));
            }
        }
    }
    int x = 0;
    for (int i = 0; i < n; i++) x += A[i];
    for (int i = x; i <= sum; i++) {
        if (dp[i][k] >= n) {
            cout << i - x << '\n';
            return 0;
        }
    }
    cout << "Impossible\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 3932 KB Output is correct
2 Correct 46 ms 3416 KB Output is correct
3 Correct 50 ms 2908 KB Output is correct
4 Correct 87 ms 4956 KB Output is correct
5 Correct 87 ms 4956 KB Output is correct
6 Correct 38 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 61 ms 3932 KB Output is correct
15 Correct 46 ms 3416 KB Output is correct
16 Correct 50 ms 2908 KB Output is correct
17 Correct 87 ms 4956 KB Output is correct
18 Correct 87 ms 4956 KB Output is correct
19 Correct 38 ms 3164 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 234 ms 49444 KB Output is correct
26 Execution timed out 1101 ms 50008 KB Time limit exceeded
27 Halted 0 ms 0 KB -