| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1282467 | abyfu | 은행 (IZhO14_bank) | C++20 | 4 ms | 572 KiB |
//OwO
//#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define namein "bank.in"
#define nameout "bank.out"
#define pque priority_queue
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define m_pi acos(-1)
using namespace std;
const ll inf = 1e18;
const int linf = 1.5e9;
void file(){
if (fopen(namein, "r")){
freopen(namein, "r", stdin);
freopen(nameout, "w", stdout);
}
}
const ll mod = 1e9 + 7;
const int N = 2e1 + 5, M = 5e5 + 5;
bool dp[N][(1 << N)];
int n, m;
int a[N], b[N];
vector<int> u[N];
void run(){
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) cin >> b[i];
dp[0][0] = 1;
int l = (1 << (m + 1)) - 1;
for (int i = 1; i <= l; i++){
int v = 0;
for (int j = 0; j <= m; j++){
if ((i >> j) & 1){
v += b[j];
}
}
for (int j = 1; j <= n; j++){
if (a[j] == v){
u[j].pb(v);
}
}
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= l; j++){
for (auto k : u[i]){
bool ax = 1;
for (int o = 0; o <= m; o++){
if ((j >> o) & 1 != (k >> o) & 1){
ax = 0;
break;
}
}
if (ax){
dp[i][j] = max(dp[i][j], dp[i - 1][j ^ k]);
}
}
}
}
for (int i = 1; i <= l; i++){
if (dp[n][i]){
cout << "YES";
return;
}
}
cout << "NO";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//file();
run();
}
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... | ||||
