# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944316 | 4QT0R | Bank (IZhO14_bank) | C++17 | 74 ms | 8580 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 sal[22];
int sal_pref[22];
int val[22];
pair<int,int> maski[1<<20];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,v;
cin >> n >> m;
for (int i = 0; i<n; i++){
cin >> sal[i];
sal_pref[i]=sal_pref[i-1]+sal[i];
}
for (int i = 0; i<m; i++)cin >> val[i];
const int zak=1<<m;
for (int i = 1; i<zak; i++){
for (int j = 0; j<m; j++){
if (i&(1<<j)){
int bez=i^(1<<j);
maski[i].second=maski[bez].second+val[j];
if (maski[i].second-sal_pref[maski[bez].first]==sal[maski[bez].first+1]){
maski[i].first=max(maski[i].first,maski[bez].first+1);
}
if (maski[i].first==n){
cout << "YES\n";
return 0;
}
}
}
}
cout << "NO\n";
}
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... |