Submission #887639

#TimeUsernameProblemLanguageResultExecution timeMemory
887639asdasdqwerBank (IZhO14_bank)C++14
71 / 100
819 ms262144 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,sse4") #include <bits/stdc++.h> using namespace std; signed main() { // clock_t start = clock(); int n, m;cin>>n>>m; vector<int> a(n); for (int &x:a)cin>>x; vector<int> b(m); for (int &x:b)cin>>x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<vector<int>> bitmasks; for (int i=0;i<n;i++) { vector<int> btm; int x = a[i]; int mx = (1 << m); for (int j=1;j<mx;j++) { int sm = 0, cp = j; int cnt=0; while (cp) { if ((cp & 1) == 1) { sm += b[m-cnt-1]; if (sm > x) break; } cnt++; cp >>= 1; } if (sm == x) { btm.push_back(j); } } if (btm.size() == 0) { cout << "NO\n"; return 0; } bitmasks.push_back(btm); } vector<int> ger; for (int x:bitmasks[0]) { ger.push_back(x); } for (int i=1;i<n;i++) { vector<int> copy; for (int x:bitmasks[i]) { for (int y:ger) { if ((x & y) == 0) { copy.push_back((x | y)); } } } ger = copy; } if (ger.size()) { cout << "YES\n"; } else { cout << "NO\n"; } // clock_t end = clock(); // double dif = ((double)end - (double)start) / CLOCKS_PER_SEC; // cout << dif << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...