Submission #748747

#TimeUsernameProblemLanguageResultExecution timeMemory
748747LKR__enjoyerBank (IZhO14_bank)C++17
52 / 100
2 ms340 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]; vector<int> curr; void evaluate(int mask){ int wyn=0; for(int i=0;i<m;i++){ int x=mask&(1<<i); if(!x)continue; wyn+=rig[i]; } if(wyn>1000)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; for(int &i:rig)cin>>i; for(int i=1;i<(1<<m);i++)evaluate(i); curr=mask_list[lef[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...