Submission #856201

#TimeUsernameProblemLanguageResultExecution timeMemory
856201ThylOneBank (IZhO14_bank)C++14
19 / 100
11 ms45488 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int n,m; vector<int> salaries; vector<int> billets; #define BS bitset bool mem[22][(1<<21)]; void initMem(){ for(int i=0;i<22;i++){ for(int j=0;j<(1<<21);j++){ mem[i][j]=false; } } } bool solved(int pos,int act,int curr,int mask){ if(pos==n){ return true; } if(curr==m)return false; if(act<0)return false; else if(act==0){ return solved(pos+1,salaries[pos+1],0,mask); } if(solved(pos,act,curr+1,mask))return true; if(!((mask>>curr)&1) && solved(pos,act-billets[curr],curr+1,mask+(1<<curr))){ return true; } return false; } signed main(){ initMem(); cin>>n>>m; salaries.resize(n); billets.resize(m); for(int i=0;i<n;i++){ cin>>salaries[i]; } for(int i=0;i<m;i++){ cin>>billets[i]; } sort(billets.begin(),billets.end()); if(solved(0,salaries[0],0,0)){ cout<<"YES\n"; }else{ cout<<"NO\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...