# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1107265 | vjudge1 | Bank (IZhO14_bank) | C++17 | 1068 ms | 592 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 <bits/stdc++.h>
// #define int long long
using namespace std;
const int N = 1e5 + 11;
const int maxn = 1e6 + 11;
const int inf = 1e9 + 7;
const int MOD = 1e9 + 7;
int n, m, a[N], b[N], ok = 0;
void f(int pos, int mm){
if(pos == n + 1) ok = 1;
if(ok) {
return;
}
for(int mask = 0; mask < (1 << m); mask++){
int brk = 0, sum = 0;
if(mask & mm) continue;
for(int i = 0; i < m; i++){
if(mask >> i & 1) sum += b[i];
}
if(sum == a[pos]) f(pos + 1, (mask | mm));
if(ok){
return;
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < m; i++) cin >> b[i];
f(0, 0);
cout << (ok? "YES":"NO");
}
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... |