제출 #748749

#제출 시각아이디문제언어결과실행 시간메모리
748749LKR__enjoyer은행 (IZhO14_bank)C++17
71 / 100
624 ms262144 KiB
#include<bits/stdc++.h> #define f first #define s second #define pb push_back typedef long long ll; #define pii pair<int,int> using namespace std; int n,m; vector<int> lef,rig; vector<int> mask_list[1001]; bitset<1001> jest; vector<int> curr; void evaluate(int mask){ int wyn=0; for(int i=0;i<m;i++)if((mask&(1<<i)))wyn+=rig[i]; if(wyn>1000||jest[wyn]==0)return; mask_list[wyn].pb(mask); } void proc(int ind){ vector<int> nex={}; for(int i : curr){ for(int j : mask_list[lef[ind]]) if((i&j)==0)nex.pb((i|j)); } curr=nex; } int main() { cin>>n>>m; lef.resize(n); rig.resize(m); for(int &i:lef){cin>>i; jest[i]=1;} for(int &i:rig)cin>>i; for(int i=0;i<(1<<m);i++)evaluate(i); curr=mask_list[lef[0]]; if(curr.empty()){cout<<"NO"; return 0;} for(int i=1;i<n;i++){ proc(i); if(curr.empty()){cout<<"NO"; return 0;} } cout<<"YES"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...