답안 #1005618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005618 2024-06-22T16:15:48 Z coolboy19521 Kitchen (BOI19_kitchen) C++17
100 / 100
21 ms 1116 KB
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
#define int long long
 
using namespace std;
 
const int sz = 3e2 + 6;
 
int a[sz], b[sz];
int dp[sz * sz];
 
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
 
    int n, m, k;
    cin >> n >> m >> k;
 
    int sm = 0;
    bool f = false;
 
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        sm += a[i];
 
        if (a[i] < k) {
            f = true;
        }
    }
 
    for (int i = 1; i <= m; i ++) {
        cin >> b[i];
    }
 
    if (f) {
        goto ex;
    }
 
    for (int i = 1; i <= m; i ++) {
        for (int j = sz * sz - 1; b[i] < j; j --) {
            if (dp[j - b[i]]) {
                dp[j] = max(dp[j], dp[j - b[i]] + min(b[i], n));
            }
        }
 
        dp[b[i]] = max(dp[b[i]], min(b[i], n));
    }
 
    for (int i = sm; i < sz * sz; i ++) {
        if (dp[i] >= n * k) {
            cout << i - sm;
            return 0;
        }
    }
 
    ex:
    cout << "Impossible";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 860 KB Output is correct
2 Correct 15 ms 860 KB Output is correct
3 Correct 21 ms 664 KB Output is correct
4 Correct 19 ms 1032 KB Output is correct
5 Correct 19 ms 964 KB Output is correct
6 Correct 14 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 17 ms 860 KB Output is correct
15 Correct 15 ms 860 KB Output is correct
16 Correct 21 ms 664 KB Output is correct
17 Correct 19 ms 1032 KB Output is correct
18 Correct 19 ms 964 KB Output is correct
19 Correct 14 ms 860 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 14 ms 860 KB Output is correct
26 Correct 16 ms 860 KB Output is correct
27 Correct 10 ms 604 KB Output is correct
28 Correct 16 ms 860 KB Output is correct
29 Correct 16 ms 772 KB Output is correct
30 Correct 19 ms 1116 KB Output is correct