제출 #1128265

#제출 시각아이디문제언어결과실행 시간메모리
1128265rasbery303은행 (IZhO14_bank)C++20
19 / 100
162 ms420 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; const int N = 1001; int n, m, a[N], b[N]; bool bit(int mask, int pos){ return (mask>>(pos-1))&1; } int main(){ cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i= 1; i <= m; ++i) cin >> b[i]; sort(a+1, a+n+1); sort(b+1, b+m+1); bool ans = true; vector<int> del; for (int i = 1; i <= n && ans; ++i){ for (int mask = 0; mask < (1<<(m+1)); ++mask){ del.clear(); int sum = 0; for (int k = 1; k <= m; ++k){ if (bit(mask, k)){ sum += b[k]; del.push_back(k); } } if (sum==a[i]){ for (int&x: del) b[x] = 0; del.clear(); break; } } // cout << "i = " << i << "\t"; // for (int j = 1; j <= m; ++j) // cout << b[j] << " \n"[j==m]; if (!del.empty()) ans = false; } cout << (ans? "YES" : "NO"); 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...