답안 #459612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
459612 2021-08-08T20:20:24 Z Ozy Kitchen (BOI19_kitchen) C++17
0 / 100
23 ms 1248 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(k,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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -