Submission #524445

# Submission time Handle Problem Language Result Execution time Memory
524445 2022-02-09T08:36:48 Z Jarif_Rahman Kitchen (BOI19_kitchen) C++17
0 / 100
80 ms 68444 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k; cin >> n >> m >> k;

    vector<int> A(n), B(m);
    int s1 = 0, s2 = 0;
    for(int &x: A){
        cin >> x, s1+=x;
        if(x < k){
            cout << "Impossible\n";
            exit(0);
        }
    }
    for(int &x: B) cin >> x, s2+=x;

    vector<vector<int>> dp(m, vector<int>(s2+1, 0));
    
    for(int i = m-1; i >= 0; i--) for(int j = s2; j >= 0; j--){
        if(j-B[i] >= 0){
            dp[i][j] = max(dp[i][j], (i != m-1 ? dp[i+1][j-B[i]]:0)+min(B[i], n));
        }
    }

    for(int i = s1; i <= s2; i++){
        if(dp[0][i] >= n*k){
            cout << i-s1 << "\n";
            exit(0);
        }
    }

    cout << "Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 68444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -