답안 #465640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465640 2021-08-16T15:39:46 Z bonopo Kitchen (BOI19_kitchen) C++14
21 / 100
26 ms 716 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define rc (i<<1)|1
#define lc (i<<1)
#define el "\n"
#define f first
#define s second

typedef long long ll;
const int MM=1e5+5, MOD=1e9+7, LOG=19;
int N, M, K, dp[MM], mn=1e9, sm;

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin>>N>>M>>K;
    for(int i=1, x; i<=N; ++i) {
        cin>>x, sm+=x, mn=min(mn, x); }
    if(mn<K) {
        return cout<<"Impossible", 0; }
    for(int i=1, x; i<=M; ++i) {
        cin>>x;
        for(int j=MM-1; j>=x; --j) dp[j]=max(dp[j], dp[j-x]+min(x, N));
    }

    for(int i=sm; i<MM; ++i) if(dp[i]>=N*K) {
        return cout<<i-sm<<el, 0; }
    cout<<"Impossible"<<el;
}

// MM
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 712 KB Output is correct
2 Correct 5 ms 588 KB Output is correct
3 Correct 4 ms 588 KB Output is correct
4 Correct 5 ms 588 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -