# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1107513 | vjudge1 | Bank (IZhO14_bank) | C++17 | 3 ms | 6992 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;
#define int long long
#define nn "\n";
#define pb push_back
#define all(v) (v).begin() , (v).end()
const int N = 2e5+ 4;
int a[N] , b[N];
vector<int>g[N];
int n , T , q , m ;
void dfs(int v , int x ){
if(v == n ){
cout << "YES";
exit(0);
}
for(auto at:g[v+1]){
if(x&at== 0 ){
x|=at;
dfs(x , v + 1 );
}
}
}
signed main(){
ios_base::sync_with_stdio(0) , cin.tie(0);
cin>> n >> m ;
for(int i=1 ; i <= n ;i++)cin>> a[i];
for(int i=0 ; i < m; i++)cin>> b[i];
for(int i = 0 ; i < (1 << m ) - 1; i++){
int sum =0 ;
for(int j =0 ; j < m; j++){
if(( i >> j )&1 ){
sum+=b[j];
}
}
g[sum].pb(i);
}
for(int i=0 ; i < g[1].size() ; i++){
dfs(1 , g[1][i]);
}
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... |