Submission #1089179

#TimeUsernameProblemLanguageResultExecution timeMemory
1089179vjudge1Bank (IZhO14_bank)C++17
19 / 100
63 ms604 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 int long long #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; } int cnt[1001],smm,smm1; Daulbekov Makan(){ // freopen(".in","r",stdin); // freopen(".out","w",stdout); accepted int n,m; cin>>n>>m; int a[n],b[m]; for(int i=0;i<n;i++){ cin>>a[i]; smm+=a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; smm1+=b[i]; } if(n>m||smm>smm1){ cout<<"NO"; return 0; } vector<int>v; 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]; } if(tot==smm){ v.pb(j); } } if(v.empty()){ cout<<"NO"; return 0; } for(auto j:v){ set<int>st; for(int i=0;i<m;i++){ if(j&(1<<i))st.insert(i); } for(int i=0;i<n;i++)cnt[a[i]]=0; int sz=st.size(); for(int mask=0;mask<(1<<sz);mask++){ int cur=0,sm=0; for(auto i:st){ if(mask&(1<<cur))sm+=b[i]; cur++; } cnt[sm]++; } bool bb=0; for(int i=0;i<n;i++){ cnt[a[i]]--; if(cnt[a[i]]<0){ bb=1; break; } } if(bb==0){ cout<<"YES"; return 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...