# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056469 | vjudge1 | Bank (IZhO14_bank) | C++17 | 2 ms | 604 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 task "rbp"
#define ii pair<int,int>
#define fi first
#define se second
#define int long long
#define ld double
#define mp make_pair
#define lg2 21
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define fii fi.fi
#define fis fi.se
#define sfi se.fi
#define see se.se
#define base 29
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
const int maxn=1e3+5;
const int mod=998244353;
const int maxi=1000;
const int them=1e6;
int n,m,a[maxn],b[maxn],vis[maxn];
ii dp[(1<<21)];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);}
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>b[i];
dp[0]={1,0};
vis[0]=1;
for(int i=1;i<(1<<m);i++)
{
for(int j=0;j<m;j++)
{
if(i&(1<<j)&&vis[i^(1<<j)])
{
ii d=dp[i^(1<<j)];
d.se+=b[j];
if(d.se<a[d.fi])
{
dp[i]=d;
vis[i]=1;
}
else if(d.se==a[d.fi])
{
vis[i]=1;
if(d.fi+1>n)
{
cout<<"YES";
return 0;
}
dp[i]={d.fi+1,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... |