Submission #567549

# Submission time Handle Problem Language Result Execution time Memory
567549 2022-05-23T17:08:22 Z birthdaycake Kitchen (BOI19_kitchen) C++17
0 / 100
22 ms 1044 KB
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
 
 
 
 
int dp[200001],a[20001],b[200001];
 
signed main(){
    boost;
    
    
    
    
    int n,m,k,sum = 0; cin >> n >> m >>  k;
    for(int i = 0; i < n; i++){
        cin >> a[i]; sum += a[i];
    }
    
    for(int j = 0; j < m; j++) cin >> b[j];
        
    if(m < k){
        cout << "Impossible";
        return 0;
    }
        
    for(int i = 0; i < n; i++){
        if(a[i] < k){
            cout << "Impossible";
            return 0;
        }
    }
    
    dp[0] = 1;
    for(int i = 0; i < m; i++){
        for(int j = 90000; j >= b[i]; j--){
            dp[j] = max(dp[j], dp[j - b[i]] + min(b[i],n));
        }
    }
    for(int i = sum; i <= 90000; i++){
        if(dp[i] >= n * k){
            cout << i - sum;
            return 0;
        }
    }
    cout << "Impossible";
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 980 KB Output is correct
2 Incorrect 4 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -