답안 #509567

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

using namespace std;

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

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 (check || ans >= inf)
        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 83 ms 222312 KB Output is correct
2 Correct 81 ms 222276 KB Output is correct
3 Correct 85 ms 222352 KB Output is correct
4 Correct 88 ms 222428 KB Output is correct
5 Correct 81 ms 222340 KB Output is correct
6 Correct 80 ms 222468 KB Output is correct
7 Correct 82 ms 222340 KB Output is correct
8 Incorrect 91 ms 222312 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 222312 KB Output is correct
2 Correct 81 ms 222276 KB Output is correct
3 Correct 85 ms 222352 KB Output is correct
4 Correct 88 ms 222428 KB Output is correct
5 Correct 81 ms 222340 KB Output is correct
6 Correct 80 ms 222468 KB Output is correct
7 Correct 82 ms 222340 KB Output is correct
8 Incorrect 91 ms 222312 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 125 ms 222308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 222320 KB Output is correct
2 Correct 88 ms 222276 KB Output is correct
3 Correct 93 ms 222268 KB Output is correct
4 Correct 90 ms 222444 KB Output is correct
5 Correct 89 ms 222332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 222312 KB Output is correct
2 Correct 81 ms 222276 KB Output is correct
3 Correct 85 ms 222352 KB Output is correct
4 Correct 88 ms 222428 KB Output is correct
5 Correct 81 ms 222340 KB Output is correct
6 Correct 80 ms 222468 KB Output is correct
7 Correct 82 ms 222340 KB Output is correct
8 Incorrect 91 ms 222312 KB Output isn't correct