| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307188 | pete555 | Bank (IZhO14_bank) | C++17 | 2 ms | 572 KiB |
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
int main()
{
cin.tie(0)->sync_with_stdio(false);
//fileIO("");
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> b(n);
for (int i = 0; i < m; i++) {
cin >> b[i];
}
map<int, vector<int>> vals;
for (int s = 0; s < (1 << m); s++) {
int val = 0;
for (int i = 0; i < m; i++) {
if (s & (1 << i)) {
val += b[i];
}
}
vals[val].pb(s);
}
vector<int> dp(1 << m);
dp[0] = 1;
for (int i = 0; i < n; i++) {
vector<int> new_dp(1 << m);
for (int s = 0; s < (1 << m); s++) {
for (int x : vals[a[i]]) {
if ((s & x) == x) {
new_dp[s] |= dp[s ^ x];
}
}
}
dp = new_dp;
}
for (int s = 0; s < (1 << m); s++) {
if (dp[s] == 1) {
cout << "YES\n";
return 0;
}
}
cout << "NO\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... | ||||
