# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1098314 | vjudge1 | Bank (IZhO14_bank) | C++17 | 149 ms | 472 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 pb push_back
#define int long long
#define S second
#define F first
#define ahah ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e6+7;
const int MOD=1e9+7;
int a[N],b[N];
bool used[N];
signed main() {
ahah
int n,m;
cin >> n >> m;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
}
sort(a+1,a+1+n);
for(int i = 1 ; i <= m ; i++){
cin >> b[i];
}
sort(b+1,b+1+m);
reverse(b+1,b+1+m);
for(int uk = 1 ; uk <= n ; uk++){
int to=a[uk];
bool ok=false;
for(int i = 0 ; i < (1 << m) ; i++){
int cnt=0;
vector<int>vc;
for(int j = 0 ; j < m ; j++){
if(i&(1 << j) and !used[j+1]){
cnt+=b[j+1];
vc.pb(j+1);
}
}
if(cnt == to){
for(int j = 0 ; j < vc.size() ; j++){
used[vc[j]]=true;
}
ok=true;
break;
}
}
if(!ok){
cout << "NO";
return 0;
}
}
cout << "YES";
}
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... |