Submission #697935

# Submission time Handle Problem Language Result Execution time Memory
697935 2023-02-11T13:55:58 Z jiahng Kitchen (BOI19_kitchen) C++14
21 / 100
164 ms 136096 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define int ll
typedef pair<int, int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair <pi,pi> pipi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 310
#define INF (ll)1e18
#define MOD 998244353
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
#define DEBUG 0
#pragma GCC optimize("trapv")
int N,M,K,A[maxn],B[maxn];
int dp[maxn][maxn*maxn];

int32_t main(){
    cin >> N >> M >> K;
    FOR(i,1,N) cin >> A[i];
    FOR(i,1,M) cin >> B[i];
    int sumA = accumulate(A+1,A+N+1,0);
    int sumB = accumulate(B+1,B+M+1,0);

    if (sumA > sumB){
        cout << "Impossible"; return 0;
    }

    FOR(i,1,N){
        if (A[i] < K){
            cout << "Impossible"; return 0;
        }
    }

    DEC(i,M,1){
        FOR(j,0,sumB){
            if (j >= B[i]) dp[i][j] = max(dp[i+1][j], dp[i+1][j-B[i]] + min(B[i], N));
            else dp[i][j] = dp[i+1][j];
        }
    }
    FOR(j,sumA,sumB) if (dp[1][j] >= K*N){
        cout << j - sumA; return 0;
    }
    cout << "Impossible";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 136096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 828 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -