답안 #509578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509578 2022-01-14T07:02:56 Z kianaRZV Kitchen (BOI19_kitchen) C++14
100 / 100
174 ms 222452 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, -63, 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 100 ms 222336 KB Output is correct
2 Correct 87 ms 222296 KB Output is correct
3 Correct 89 ms 222276 KB Output is correct
4 Correct 82 ms 222296 KB Output is correct
5 Correct 96 ms 222324 KB Output is correct
6 Correct 80 ms 222452 KB Output is correct
7 Correct 88 ms 222308 KB Output is correct
8 Correct 81 ms 222308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 222336 KB Output is correct
2 Correct 87 ms 222296 KB Output is correct
3 Correct 89 ms 222276 KB Output is correct
4 Correct 82 ms 222296 KB Output is correct
5 Correct 96 ms 222324 KB Output is correct
6 Correct 80 ms 222452 KB Output is correct
7 Correct 88 ms 222308 KB Output is correct
8 Correct 81 ms 222308 KB Output is correct
9 Correct 83 ms 222312 KB Output is correct
10 Correct 82 ms 222352 KB Output is correct
11 Correct 81 ms 222292 KB Output is correct
12 Correct 101 ms 222320 KB Output is correct
13 Correct 86 ms 222364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 222396 KB Output is correct
2 Correct 132 ms 222384 KB Output is correct
3 Correct 174 ms 222396 KB Output is correct
4 Correct 128 ms 222372 KB Output is correct
5 Correct 126 ms 222324 KB Output is correct
6 Correct 119 ms 222276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 222384 KB Output is correct
2 Correct 109 ms 222380 KB Output is correct
3 Correct 87 ms 222360 KB Output is correct
4 Correct 98 ms 222332 KB Output is correct
5 Correct 87 ms 222356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 222336 KB Output is correct
2 Correct 87 ms 222296 KB Output is correct
3 Correct 89 ms 222276 KB Output is correct
4 Correct 82 ms 222296 KB Output is correct
5 Correct 96 ms 222324 KB Output is correct
6 Correct 80 ms 222452 KB Output is correct
7 Correct 88 ms 222308 KB Output is correct
8 Correct 81 ms 222308 KB Output is correct
9 Correct 83 ms 222312 KB Output is correct
10 Correct 82 ms 222352 KB Output is correct
11 Correct 81 ms 222292 KB Output is correct
12 Correct 101 ms 222320 KB Output is correct
13 Correct 86 ms 222364 KB Output is correct
14 Correct 119 ms 222396 KB Output is correct
15 Correct 132 ms 222384 KB Output is correct
16 Correct 174 ms 222396 KB Output is correct
17 Correct 128 ms 222372 KB Output is correct
18 Correct 126 ms 222324 KB Output is correct
19 Correct 119 ms 222276 KB Output is correct
20 Correct 95 ms 222384 KB Output is correct
21 Correct 109 ms 222380 KB Output is correct
22 Correct 87 ms 222360 KB Output is correct
23 Correct 98 ms 222332 KB Output is correct
24 Correct 87 ms 222356 KB Output is correct
25 Correct 113 ms 222444 KB Output is correct
26 Correct 153 ms 222388 KB Output is correct
27 Correct 118 ms 222348 KB Output is correct
28 Correct 114 ms 222364 KB Output is correct
29 Correct 117 ms 222392 KB Output is correct
30 Correct 123 ms 222396 KB Output is correct