| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292957 | redminote13pro | 은행 (IZhO14_bank) | C++20 | 53 ms | 44928 KiB |
#include <bits/stdc++.h>
using namespace std;
#define print(a) for(auto x : a){cout << x << " ";}
#define scan(a) for(auto & x : a) {cin >> x;}
#define rall(a) a.rbegin() , a.rend()
#define all(a) a.begin() , a.end()
#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int , int>;
const ll MOD = 1e9 + 7 , INF = 1e18 , LOG = 20 , N = 1e5 + 5;
inline void solve(){
int n , m;
cin >> n >> m;
vector<int> a(n);
scan(a);
vector<int> b(m);
scan(b);
int used = 0;
for(auto x : a){
bool flag = false;
for(int mask = 0; mask < (1 << m); mask++){
if(mask & used) continue;
int sum = 0;
for(int j = 0; j < m; j++){
if(mask & (1 << j)){
sum += b[j];
}
}
if(sum == x){
used |= mask;
flag = true;
break;
}
}
if(!flag) return cout << "NO\n" , void();
}
cout << "YES\n";
}
signed main(void){
freopen("bank.in", "r", stdin);
freopen("bank.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tt = 1;
//cin >> tt;
while(tt--){
solve();
}
cout << "\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... | ||||
