# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669099 |
2022-12-05T16:28:30 Z |
amin |
Bank (IZhO14_bank) |
C++14 |
|
5 ms |
596 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long n,m;
cin>>n>>m;
map<long ,long>ma;
long a[n];
long b[n];
long ans[1<<m];
vector<long>v;
long sum=0;
for(long i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
v.push_back(sum);
}
for(long i=0;i<m;i++)
{
cin>>b[i];
}
for(long i=0;i<(1<<m);i++)
{
ans[i]=-1;
}
ans[0]=1;
long o=0;
long p=0;
for(long i=1;i<(1<<m);i++)
{
o=0;
p=0;
for(long y=0;y<m;y++)
{
if(i&(1<<y))
{
o+=b[y];
}
}
// cout<<i<<' ';
for(long y=0;y<m;y++)
{
if(i&(1<<y))
{
long u=i-(1<<y);
p=o-b[y];
if(ans[u]==-1)
{
continue;
}
if(upper_bound(v.begin(),v.end(),o)==upper_bound(v.begin(),v.end(),p))
{
ans[i]=1;
break;
}
if(lower_bound(v.begin(),v.end(),o)!=upper_bound(v.begin(),v.end(),o)&&lower_bound(v.begin(),v.end(),o)==upper_bound(v.begin(),v.end(),p))
{
ans[i]=1;
break;
}
}
}
// cout<<o<<' '<<ans[i]<<endl;
ma[o]=max(ma[o],ans[i]);
}
if(ma[sum]==1)
{
cout<<"YES"<<endl;
}else
cout<<"NO"<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
596 KB |
Output is correct |
2 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |