답안 #708959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708959 2023-03-12T22:19:21 Z stevancv Kitchen (BOI19_kitchen) C++14
0 / 100
22 ms 640 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 300 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
int a[N], b[N], dp[N * N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    int moze = 1;
    int sa, sb;
    sa = sb = 0;
    for (int i = 1; i <= n; i++) {
        sa += a[i];
        if (a[i] < k) moze = 0;
    }
    for (int i = 1; i <= m; i++) sb += b[i];
    if (moze == 0) {
        cout << "Impossible" << en;
        return 0;
    }
    for (int i = 1; i < N * N; i++) dp[i] = -inf;
    for (int i = 1; i <= m; i++) {
        for (int j = N * N - 1; j >= b[i]; j--) smax(dp[j], dp[j - b[i]] + min(b[i], n));
    }
    for (int i = sa; i < N; i++) {
        if (dp[i] >= n * k) {
            cout << i - sa << en;
            return 0;
        }
    }
    cout << "Impossible" << en;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Halted 0 ms 0 KB -