# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013025 | vjudge1 | Bank (IZhO14_bank) | C++17 | 1012 ms | 8272 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>
using namespace std;
int n, m, a[1001], b[1001];
vector<int> v[20001];
void rec(int i, int mask){
if(i == n){
cout << "YES";
exit(0);
}
for(auto to : v[a[i]]){
if((to & mask) == 0){
rec(i+1, mask ^ to);
}
}
}
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 j = 0; j < m; j++){
cin >> b[j];
}
for(int mask = 0; mask < (1<<m); mask++){
int sum = 0;
for(int j = 0; j < m; j++){
if(mask & (1 << j)){
sum += b[j];
}
}
v[sum].push_back(mask);
}
rec(0, 0);
cout << "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... |