제출 #528160

#제출 시각아이디문제언어결과실행 시간메모리
528160CursedCode은행 (IZhO14_bank)C++14
19 / 100
84 ms8472 KiB
#include<bits/stdc++.h> using namespace std; int covered[(1<<20)],leftover[(1<<20)]; int main(){ int n,m,i,j,a[21],b[21]; cin >> n >> m; for(i = 0;i < n;i++){ cin >> a[i]; } for(i = 0;i < m;i++){ cin >> b[i]; } leftover[0] = 0; covered[0] = 0; for(i = 1;i < (1 << m);i++){ for(j = 0;j < m;j++){ if(i & (1 << j)){ int ih = i ^ (1 << j); if(leftover[ih] + b[j] < a[covered[ih]]){ leftover[i] = leftover[ih] + b[j]; covered[i] = covered[ih]; } if(leftover[ih] + b[j] == a[covered[ih]]){ leftover[i] = 0; covered[i] = covered[ih] + 1; } } } if(covered[i] == n){ cout << "YES"; return 0; } } 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...