# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
873289 | asdasdqwer | Bank (IZhO14_bank) | C++17 | 825 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
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";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |