# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961535 | doducanh | Bank (IZhO14_bank) | C++14 | 74 ms | 8488 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;
int leftovers[(1<<20)+7];
int people_cover[(1<<20)+7];
int a[25],b[25];
int n,m;
main()
{
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>b[i];
for(int mask=1;mask<(1<<m);mask++){
for(int i=0;i<=m;i++){
if((mask>>i)&1){
int prev=(mask^(1<<i));
int amt=leftovers[mask]+b[i];
if(amt<a[people_cover[mask]]){
leftovers[mask]=amt;
people_cover[mask]=people_cover[prev];
}
else if(amt==a[people_cover[mask]]){
leftovers[mask]=0;
people_cover[mask]=people_cover[prev]+1;
}
}
}
if(people_cover[mask]==n){
cout<<"YES";
return 0;
}
}
cout<<"NO";
return 0;
}
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... |