제출 #465422

#제출 시각아이디문제언어결과실행 시간메모리
465422bonopoKitchen (BOI19_kitchen)C++14
21 / 100
9 ms460 KiB
#include <bits/stdc++.h>
using namespace std;
#define el "\n"

typedef long long ll;
const int MM = 1e5+5, MOD = 1e9+7;
int N, M, K, wst = 1e9, sum, dp[MM];

int main() {
    cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
    cin >> N >> M >> K;
    for(int i = 1, x; i <= N; i++) cin >> x, wst = min(wst, x), sum += x;
    if(wst < K) { cout << "Impossible" << el; return 0; }
    for(int i = 1, x, s = 0; i <= M; i++) {
        cin >> x; s += x;
        for(int j = s; j >= 0; j--) {
            dp[j+x] = max(dp[j+x], dp[j] + min(x, N)); }
    } for(int i = sum; i < MM; i++) if(dp[i] >= N*K) { cout << i - sum << el; return 0; }
    cout << "Impossible" << el;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...