Submission #1089402

#TimeUsernameProblemLanguageResultExecution timeMemory
1089402vjudge1Bank (IZhO14_bank)C++17
100 / 100
324 ms4432 KiB
#include <bits/stdc++.h> using namespace std; #define accepted ios_base::sync_with_stdio(0);cin.tie(0); #define Daulbekov signed #define Makan main #define double long double #define pb push_back #define F first #define S second const long long N=5e5+10; const long long MOD=1e9+7; const long long INF=2e18; int binpow(int a,int b){ a%=MOD; if(b==0)return 1; if(b%2)return binpow(a,b-1)*a%MOD; else { int res=binpow(a,b/2); return res*res%MOD; } } bool cmp(pair<int,int>a,pair<int,int>b){ if(a.F/300!=b.F/300)return a.F/300<b.F/300; return a.S<b.S; } vector<int>g[1001]; int a[21],b[21],n,m,used[(1<<20)+1]; void get(int v,int mask){ if(v==n){ cout<<"YES"; exit(0); } if(used[mask])return; used[mask]=1; for(auto to:g[a[v]]){ if(!(mask&to)&&used[mask|to]==0){ get(v+1,(mask|to)); } } } Daulbekov Makan(){ // freopen(".in","r",stdin); // freopen(".out","w",stdout); accepted cin>>n>>m; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; if(n>m){ cout<<"NO"; return 0; } for(int j=0;j<(1<<m);j++){ int tot=0; for(int i=0;i<m;i++){ if(j&(1<<i))tot+=b[i]; } for(int i=0;i<n;i++){ if(tot==a[i]){ g[a[i]].pb(j); } } } get(0,0); 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...