제출 #752689

#제출 시각아이디문제언어결과실행 시간메모리
752689beaconmc은행 (IZhO14_bank)C++14
100 / 100
215 ms12576 KiB
#include <bits/stdc++.h> typedef long long ll; #define FOR(i,x,y) for (ll i = (x); i < (y); i++) using namespace std; set<ll> dp[21]; map<ll, vector<ll>> idk; //cd "/home/s/saco06/Desktop/" && g++ bank.cpp -o bank && "/home/s/saco06/Desktop/"bank int main(){ ll n,m; cin >> n >> m; ll sum1=0, sum2=0; vector<ll> lis1(n); vector<ll> lis2(m); FOR(i,0,n){ cin >> lis1[i]; sum1 += lis1[i]; } FOR(i,0,m){ cin >> lis2[i]; sum2 += lis2[i]; } if (sum1 > sum2){ cout << "NO"; return 0; } for (auto&i : lis1){ idk[i] = {}; } FOR(i, 0, (1<<m)){ ll sum = 0; FOR(j,0,m){ if (i & (1<<j)){ sum += lis2[j]; } } if (idk.count(sum)){ idk[sum].push_back(i); } } sort(lis1.begin(), lis1.end()); for (auto&i : idk[lis1[0]]){ dp[0].insert(i); } FOR(i, 0, n-1){ for (auto&j : dp[i]){ for (auto&k : idk[lis1[i+1]]){ if (j&k) continue; dp[i+1].insert(j|k); } } } if (dp[n-1].size()){ cout << "YES"; }else{ cout << "NO"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...