답안 #519730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519730 2022-01-27T07:45:05 Z K4YAN Kitchen (BOI19_kitchen) C++17
100 / 100
36 ms 1640 KB
//Be Name Khoda

#include<bits/stdc++.h>
#pragma GCC optmize("Ofast,unroll-loops")
#pragma GCC target ("avx2,tune=native")

using namespace std;

#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define plll pair<pll, ll>

const ll mxn = 316;
ll n, m, k, q, w;
ll dp[mxn * mxn], mx[mxn * mxn];
vector<ll> a, b;

void input() {

    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) {
        cin >> q;
        a.push_back(q);
        w += q;
    }
    for(int i = 0; i < m; i++) {
        cin >> q;
        b.push_back(q);
    }

}

void solve() {

    if(m < k) {
        cout << "Impossible\n";
        return;
    }
    for(auto u : a) {
        if(u < k) {
            cout << "Impossible\n";
            return;
        }
    }
    dp[0] = 1;
    for(auto u : b) {
        for(int i = mxn * mxn - 1; i > u - 1; i--) {
            if(dp[i - u]) {
                dp[i] = 1;
                mx[i] = max(mx[i], mx[i - u] + min(n, u));
            }
        }
    }
    for(int i = w; i < mxn * mxn; i++) {
        if(mx[i] < n * k) continue;
        cout << i - w << endl;
        return;
    }
    cout << "Impossible\n";
    return;

}

int main() {

    ios::sync_with_stdio(false); cin.tie(NULL);

    input(), solve();   

    return 0;

}

Compilation message

kitchen.cpp:4: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
    4 | #pragma GCC optmize("Ofast,unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 324 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1340 KB Output is correct
2 Correct 25 ms 1172 KB Output is correct
3 Correct 32 ms 1068 KB Output is correct
4 Correct 33 ms 1572 KB Output is correct
5 Correct 36 ms 1640 KB Output is correct
6 Correct 25 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 324 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 7 ms 340 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 324 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 28 ms 1340 KB Output is correct
15 Correct 25 ms 1172 KB Output is correct
16 Correct 32 ms 1068 KB Output is correct
17 Correct 33 ms 1572 KB Output is correct
18 Correct 36 ms 1640 KB Output is correct
19 Correct 25 ms 1016 KB Output is correct
20 Correct 5 ms 324 KB Output is correct
21 Correct 4 ms 332 KB Output is correct
22 Correct 7 ms 340 KB Output is correct
23 Correct 6 ms 332 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 23 ms 1156 KB Output is correct
26 Correct 28 ms 1276 KB Output is correct
27 Correct 17 ms 716 KB Output is correct
28 Correct 27 ms 1092 KB Output is correct
29 Correct 27 ms 1312 KB Output is correct
30 Correct 32 ms 1504 KB Output is correct