Submission #492438

# Submission time Handle Problem Language Result Execution time Memory
492438 2021-12-07T10:31:23 Z niloyroot Kitchen (BOI19_kitchen) C++14
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pl = pair<ll,ll>;
#define pb push_back
#define form(m,it) for(auto it=m.begin(); it!=m.end(); it++)
#define forp(i,a,b) for(ll i=a; i<=b; i++)
#define forn(i,a,b) for(ll i=a; i>=b; i--)
#define newl '\n'
#define ff first
#define ss second
const ll mod = 1000000007;

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    ll a[n+1];
    ll b[n+1];
    ll sum=0;
    forp(i,1,n){
        cin>>a[i];
        sum+=a[i];
    }
    forp(i,1,m){
        cin>>b[i];
    }

    ll ans=INT_MAX;
    ll temp,cnt;
    forp(i,0,(1<<m)-1){
        temp=0;
        cnt=0;
        forp(j,0,m-1){
            if(i&(1<<j)){
                temp+=a[j+1];
                cnt+=(min(n,a[j+1]));
            }
        }

        if(temp>=sum){
            if(cnt>=n*k){
                ans=min(ans,temp-sum);
            }
        }
    }
    if(ans==INT_MAX){
        cout<<"Impossible"<<newl;
    } else {
        cout<<ans<<newl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; //cin>>t;
    while(t--)solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -