| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292368 | kam | 은행 (IZhO14_bank) | C++20 | 1 ms | 572 KiB |
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<cassert>
#include<numeric>
#include<vector>
#include<string>
#include<chrono>
#include<random>
#include<stack>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<ios>
using namespace std;
int n, m;
vector<int>a, b;
vector<vector<int>>gp;
bool dfs(int id, int vis) {
if (id == n) return true;
for (int& x : gp[a[id]]) {
if ((vis ^ x) == (vis | x)) {
if (dfs(id + 1, vis | x)) return true;
}
}
return false;
}
void solve()
{
cin >> n >> m;
a = vector<int>(n);
b = vector<int>(m);
gp = vector<vector<int>>(1 << m);
for (int i = 0; i < n; i++) cin >> a[i];
for (int j = 0; j < m; j++) cin >> b[j];
for (int i = 0; i < (1 << m); i++) {
int sum = 0;
for (int j = 0; j < m; j++) {
if ((1 << j) & i) sum += b[j];
}
gp[sum].push_back(i);
}
cout << (dfs(0, 0) ? "YES" : "NO");
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen("bank.in", "r", stdin);
freopen("bank.out", "w", stdout);
//signed _; cin >> _; while (_--)
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... | ||||
