답안 #459649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
459649 2021-08-08T21:49:18 Z Ozy Kitchen (BOI19_kitchen) C++17
100 / 100
38 ms 1600 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 300
#define MAX2 90000
#define p first
#define usa second

pair<lli,lli> total[MAX2];
lli n,m,k,a,sum,sc;
bool res;
lli arr[MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;
    res = true;

    rep(i,1,n) {
        cin >> a;
        if (a < k) res = false;
        sum += a;
    }
    rep(i,1,m) {cin >> arr[i]; sc+=arr[i];}

    if (!res || sc < sum || m < k) {cout << "Impossible"; return 0;}

    total[0].p = 1;
    rep(i,1,m) {
        a = arr[i];
        repa(j,sc,0) {
            if (total[j].p == 1) {
                total[j+a].p = 1;
                total[j+a].usa = max(total[j+a].usa, (min(n,a) + total[j].usa));
            }
        }
    }

    a = k*n;
    rep(i,sum,sc) {
        if (total[i].p == 0) continue;
        if (total[i].usa >= a) {
            cout << (i-sum);
            return 0;
        }
    }

    cout << "Impossible";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1280 KB Output is correct
2 Correct 22 ms 1100 KB Output is correct
3 Correct 21 ms 1060 KB Output is correct
4 Correct 38 ms 1516 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 17 ms 1076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 27 ms 1280 KB Output is correct
15 Correct 22 ms 1100 KB Output is correct
16 Correct 21 ms 1060 KB Output is correct
17 Correct 38 ms 1516 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 17 ms 1076 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 19 ms 1236 KB Output is correct
26 Correct 25 ms 1304 KB Output is correct
27 Correct 7 ms 716 KB Output is correct
28 Correct 19 ms 1092 KB Output is correct
29 Correct 25 ms 1348 KB Output is correct
30 Correct 37 ms 1600 KB Output is correct