# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1107616 | julia_08 | Bank (IZhO14_bank) | C++17 | 1 ms | 336 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;
const int MAXN = 1e3 + 10;
int a[MAXN], b[MAXN];
int dp[1 << 21], sum[MAXN];
vector<int> v[MAXN];
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, m; cin >> n >> m;
for(int i=0; i<n; i++){
cin >> a[i];
}
for(int i=0; i<m; i++){
cin >> b[i];
}
for(int s=1; s<(1 << m); s++){
int bit = __builtin_ctz(s);
sum[s] = sum[s ^ bit] + b[bit];
}
for(int i=0; i<n; i++){
for(int s=0; s<(1 << m); s++){
if(sum[s] == a[i]) v[i].push_back(s);
}
}
for(int s=0; s<(1 << m); s++){
int i = dp[s] + 1;
for(auto x : v[i]){
if(x & s == 0){
dp[s ^ x] = max(dp[s ^ x], i);
}
}
}
cout << (dp[(1 << m) - 1] == n - 1 ? "YES" : "NO") << "\n";
return 0;
}
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... |