답안 #509553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509553 2022-01-14T06:41:30 Z kianaRZV Kitchen (BOI19_kitchen) C++14
21 / 100
88 ms 111356 KB
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int maxn = 3e2 + 5, inf = 1e9 + 9;
int n, m, k, ans = inf, sum;
int a[maxn], b[maxn], dp[maxn][maxn * maxn];
bool check;

void read_input() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        check |= (a[i] < k);
    }
    for (int i = 1; i <= m; i++)
        cin >> b[i];
}

void solve() {
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
        for (int j = 0; j < maxn * maxn; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - b[i] >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - b[i]] + min(n, b[i]));
            if (j >= sum && dp[i][j] >= n * k)
                ans = min(ans, j - sum);
        }
    if (ans == inf || check)
        cout << "Impossible";
    else
        cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    read_input(), solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 111260 KB Output is correct
2 Correct 47 ms 111248 KB Output is correct
3 Correct 46 ms 111236 KB Output is correct
4 Correct 41 ms 111244 KB Output is correct
5 Correct 41 ms 111236 KB Output is correct
6 Correct 42 ms 111356 KB Output is correct
7 Correct 44 ms 111284 KB Output is correct
8 Incorrect 42 ms 111340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 111260 KB Output is correct
2 Correct 47 ms 111248 KB Output is correct
3 Correct 46 ms 111236 KB Output is correct
4 Correct 41 ms 111244 KB Output is correct
5 Correct 41 ms 111236 KB Output is correct
6 Correct 42 ms 111356 KB Output is correct
7 Correct 44 ms 111284 KB Output is correct
8 Incorrect 42 ms 111340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 88 ms 111340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 111252 KB Output is correct
2 Correct 45 ms 111336 KB Output is correct
3 Correct 48 ms 111348 KB Output is correct
4 Correct 46 ms 111236 KB Output is correct
5 Correct 50 ms 111220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 111260 KB Output is correct
2 Correct 47 ms 111248 KB Output is correct
3 Correct 46 ms 111236 KB Output is correct
4 Correct 41 ms 111244 KB Output is correct
5 Correct 41 ms 111236 KB Output is correct
6 Correct 42 ms 111356 KB Output is correct
7 Correct 44 ms 111284 KB Output is correct
8 Incorrect 42 ms 111340 KB Output isn't correct