# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173484 | tourist | Bank (IZhO14_bank) | C++14 | 76 ms | 4524 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.
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;
const int mod = 1e9 + 7; /// ANOTHER HASH MOD: 228228227
const int prime = 29; /// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);
int n, m;
vector < int > done;
vector < int > a, b, dp;
inline void read() {
scanf("%d %d", &n, &m);
a.resize(n);
b.resize(m);
done.resize(2000);
dp.resize(1 << m);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
done[a[i]]++;
}
for (int i = 0; i < m; i++) {
scanf("%d", &b[i]);
}
}
inline int solve() {
for (int i = 0; i < (1 << m); i++) {
int sum = 0;
for (int j = 0; j < m; j++) {
if (i >> j & 1) {
sum += b[j];
}
}
if (done[sum]) {
return cout << "YES" << endl, 0;
}
}
cout << "NO" << endl;
}
int main() {
int t = 1;
while (t--) {
read();
solve();
}
}
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... |