Submission #1133370

#TimeUsernameProblemLanguageResultExecution timeMemory
1133370lopkusBank (IZhO14_bank)C++20
100 / 100
401 ms25924 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MX = 1e5 + 5; vector<int> inc[MX]; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n); vector<int> b(m); for(int i = 0; i < n; i++) { cin >> a[i]; } for(int i = 0; i < m; i++) { cin >> b[i]; } for(int bitmask = 0; bitmask < (1LL << m); bitmask++) { int sum = 0; for(int j = 0; j < m; j++) { if(bitmask & (1LL << j)) { sum += b[j]; } } inc[sum].push_back(bitmask); } vector<int> prev; prev.push_back(0); for(int i = 0; i < n; i++) { vector<int> qn; vector<int> was((1LL << m), 0); for(auto x : inc[a[i]]) { for(auto y : prev) { if((x & y) || was[x ^ y]) { continue; } qn.push_back((x ^ y)); was[x ^ y] = 1; } } prev = qn; } cout << (prev.size()? "YES" : "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...