# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058269 | vjudge1 | Bank (IZhO14_bank) | C++17 | 71 ms | 14780 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>
#define ii pair<int,int>
using namespace std;
int n ,m, a[22],b[22],d[(1<<20)+2];
ii f[(1<<22)];
main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m;
for(int i =1 ;i<=n;i++) cin>>a[i];
for(int i=0;i<m;i++) cin>>b[i];
f[0]={1,0};
d[0]=1;
for(int mask = 1 ;mask<(1<<m);mask++)
for(int i = 0 ;i<m;i++)
if(mask>>i&1)
if(d[mask^(1<<i)])
{
ii tmp = f[mask^(1<<i)];
tmp.second+=b[i];
if(tmp.second<a[tmp.first])
{
f[mask]=tmp;
d[mask]=1;
}
else if(tmp.second==a[tmp.first])
{
f[mask]={tmp.first+1,0};
d[mask]=1;
}
}
for(int i =1 ;i<(1<<m);i++)
if(f[i].first>n)
{
cout<<"YES";
return 0;
}
cout<<"NO";
}
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... |