답안 #509575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509575 2022-01-14T07:01:06 Z kianaRZV Kitchen (BOI19_kitchen) C++14
100 / 100
110 ms 119752 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 305, inf = 1e9 + 9;
int n, m, k, ans = inf, sum;
int a[maxn], b[maxn], dp[maxn][100005];
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, -63, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
        for (int j = 0; j < 100005; 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 52 ms 119620 KB Output is correct
2 Correct 55 ms 119608 KB Output is correct
3 Correct 53 ms 119608 KB Output is correct
4 Correct 59 ms 119648 KB Output is correct
5 Correct 51 ms 119596 KB Output is correct
6 Correct 45 ms 119596 KB Output is correct
7 Correct 46 ms 119580 KB Output is correct
8 Correct 47 ms 119620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 119620 KB Output is correct
2 Correct 55 ms 119608 KB Output is correct
3 Correct 53 ms 119608 KB Output is correct
4 Correct 59 ms 119648 KB Output is correct
5 Correct 51 ms 119596 KB Output is correct
6 Correct 45 ms 119596 KB Output is correct
7 Correct 46 ms 119580 KB Output is correct
8 Correct 47 ms 119620 KB Output is correct
9 Correct 55 ms 119648 KB Output is correct
10 Correct 59 ms 119616 KB Output is correct
11 Correct 52 ms 119632 KB Output is correct
12 Correct 53 ms 119652 KB Output is correct
13 Correct 58 ms 119620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 119660 KB Output is correct
2 Correct 84 ms 119672 KB Output is correct
3 Correct 102 ms 119656 KB Output is correct
4 Correct 95 ms 119624 KB Output is correct
5 Correct 96 ms 119680 KB Output is correct
6 Correct 85 ms 119668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 119752 KB Output is correct
2 Correct 54 ms 119652 KB Output is correct
3 Correct 55 ms 119580 KB Output is correct
4 Correct 67 ms 119672 KB Output is correct
5 Correct 56 ms 119628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 119620 KB Output is correct
2 Correct 55 ms 119608 KB Output is correct
3 Correct 53 ms 119608 KB Output is correct
4 Correct 59 ms 119648 KB Output is correct
5 Correct 51 ms 119596 KB Output is correct
6 Correct 45 ms 119596 KB Output is correct
7 Correct 46 ms 119580 KB Output is correct
8 Correct 47 ms 119620 KB Output is correct
9 Correct 55 ms 119648 KB Output is correct
10 Correct 59 ms 119616 KB Output is correct
11 Correct 52 ms 119632 KB Output is correct
12 Correct 53 ms 119652 KB Output is correct
13 Correct 58 ms 119620 KB Output is correct
14 Correct 92 ms 119660 KB Output is correct
15 Correct 84 ms 119672 KB Output is correct
16 Correct 102 ms 119656 KB Output is correct
17 Correct 95 ms 119624 KB Output is correct
18 Correct 96 ms 119680 KB Output is correct
19 Correct 85 ms 119668 KB Output is correct
20 Correct 59 ms 119752 KB Output is correct
21 Correct 54 ms 119652 KB Output is correct
22 Correct 55 ms 119580 KB Output is correct
23 Correct 67 ms 119672 KB Output is correct
24 Correct 56 ms 119628 KB Output is correct
25 Correct 98 ms 119672 KB Output is correct
26 Correct 98 ms 119668 KB Output is correct
27 Correct 79 ms 119672 KB Output is correct
28 Correct 110 ms 119668 KB Output is correct
29 Correct 90 ms 119628 KB Output is correct
30 Correct 102 ms 119684 KB Output is correct