# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958137 | ezzzay | Kitchen (BOI19_kitchen) | C++14 | 1 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
const int N=550;
int a[N];
int b[N];
signed main(){
int n,m,k;
cin>>n>>m>>k;
int s=0;
for(int i=1;i<=n;i++){
cin>>a[i];
s+=a[i];
}
for(int i=1;i<=m;i++)cin>>b[i];
for(int i=1;i<=n;i++){
if(a[i]<k){
cout<<"IMPOSSIBLE";
return 0;
}
}
int ans=1e9;
for(int i=0;i<(1<<m);i++){
int tmp=0;
int t=0;
int cnt=0;
for(int j=0;j<m;j++){
if(i& (1<<j)){
cnt++;
tmp+=b[j+1];
}
}
if(cnt<k or tmp<s)continue;
ans=min(ans,tmp-s);
}
if(ans==1e9){
cout<<"IMPOSSIBLE";
}
else cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |