Submission #526603

#TimeUsernameProblemLanguageResultExecution timeMemory
526603CursedCodeBank (IZhO14_bank)C++14
19 / 100
65 ms332 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,i,j,a[25],b[25],dp[25] = {0},cnt = 0; cin >> n >> m; for(i = 0;i < n;i++){ cin >> b[i]; } sort(b,b+n); for(i = 0;i < m;i++){ cin >> a[i]; } cnt = 0; sort(a,a+m); for(i = 0;i < (1 << m);i++){ int s = 0,flag = 0; for(j = 0;j < m;j++){ if(dp[j] == 1){ flag = 1; break; } if(i & (1 << j)){ s+= a[j]; } } if(flag == 1){ continue; } if(s == b[cnt]){ //cout << i << endl << endl << endl << s << endl; for(j = 0;j < m;j++){ if(i & (1 << j)){ dp[j] = 1; //cout << j << ' '; } } cnt++; if(cnt == n) break; } } if(cnt == n) cout << "YES"; else cout << "NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...