Submission #963572

#TimeUsernameProblemLanguageResultExecution timeMemory
963572maxFedorchukBank (IZhO14_bank)C++17
71 / 100
1057 ms600 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2,sse4,popcnt,bmi") #pragma GCC optimize("Ofast,unroll-loops") using namespace std; const long long MX=22; int a[MX],b[MX]; int n,m; void cnt(int msk,int in,int zalsum,int munin) { if(in>n) { cout<<"YES\n"; exit(0); } if(zalsum==0) { cnt(msk,in+1,a[in+1],0); return; } for(int i=munin+1;i<=m;i++) { if(!((msk>>i)&1) && zalsum>=b[i]) { cnt(msk|(1<<i),in,zalsum-b[i],i); } } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=m;i++) { cin>>b[i]; } cnt(0,1,a[1],0); 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...