# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
892742 | ASN49K | Bank (IZhO14_bank) | C++14 | 98 ms | 8796 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 all(x) x.begin(),x.end()
#define pb push_back
#define bug(x) cerr<<#x<<" ( "<<x<<endl
using i64=long long;
const int inf=1e9;
main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
vector<int>a(n);
vector<int>b(m);
for(auto &c:a)cin>>c;
for(auto &c:b)cin>>c;
vector<pair<int,int>>dp(1<<m,{0,0});
for(int i=1;i<(1<<m);i++)
{
for(int j=0;j<m;j++)
{
if(i&(1<<j))
{
auto nou=dp[i^(1<<j)];
nou.second+=b[j];
if(nou.second==a[nou.first])
{
nou.first++;
nou.second=0;
}
if(nou.first==n)
{
cout<<"YES\n";
return 0;
}
dp[i]=max(dp[i],nou);
}
}
}
cout<<"NO\n";
}
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... |