Submission #68447

#TimeUsernameProblemLanguageResultExecution timeMemory
68447cdemirerBank (IZhO14_bank)C++17
44 / 100
241 ms50204 KiB
#include <bits/stdc++.h> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<vii> vvii; typedef pair<double, double> dodo; #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) int N, M; int A[20], B[20]; unordered_map<int, int> table; int main(int argc, char **argv) { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for (int i = 0; i < N; i++) cin >> A[i]; sort(A, A+N);// reverse(A, A+N); for (int i = 0; i < M; i++) cin >> B[i]; sort(B, B+M);// reverse(B, B+M); int mlim = 1<<M; int used = 0; for (int i = 0; i < N; i++) { bool flag = false; for (int m = mlim-1; m > 0; m--) { if (m & used) continue; if (!table[m]) { int sum = 0; for (int k = 0; k < M; k++) if (m & (1<<k)) sum += B[k]; table[m] = sum; //cerr << "m: " << m << " val: " << table[m] << endl; } if (table[m] == A[i]) { used |= m; flag = true; break; } } if (!flag) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; 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...