Submission #963578

#TimeUsernameProblemLanguageResultExecution timeMemory
963578maxFedorchukBank (IZhO14_bank)C++17
19 / 100
6 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,int k0) { if(in>n) { cout<<"YES\n"; exit(0); } if(zalsum==0) { cnt(msk,in+1,a[in+1],0,k0); return; } if(k0<(n-in+1)) { return; } for(int i=munin+1;i<=m;i++) { if(!((msk>>i)&1)) { if(zalsum>=b[i]) { cnt(msk|(1<<i),in,zalsum-b[i],i,k0-1); } else { break; } } } } 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]; } sort(b+1,b+1+n); cnt(0,1,a[1],0,m); 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...