Submission #578432

#TimeUsernameProblemLanguageResultExecution timeMemory
578432hackerbhaiyaBank (IZhO14_bank)C++14
100 / 100
128 ms16844 KiB
#include<bits/stdc++.h> // #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") // #pragma GCC optimization("unroll-loops") // #pragma GCC optimize("unroll-loops") // #pragma GCC optimize("fast-math") // #pragma GCC optimize("no-stack-protector") // #define ll __int128 #define ll long long // #define ll int #define f(i,a,b) for(ll i=a;i<b;i++) #define mod 1000000007 // #define mod 998244353 #define mp make_pair #define uniq(v) (v).erase(unique(all(v)),(v).end()) #define ff first #define ss second #define rf(i,a,b) for(ll i=a;i>=b;i--) #define sc(a) scanf("%lld",&a) #define pf printf #define sz(a) (int)(a.size()) #define psf push_front #define ppf pop_front #define ppb pop_back #define pb push_back #define pq priority_queue #define all(s) s.begin(),s.end() #define sp(a) setprecision(a) #define rz resize #define ld long double #define inf (ll)1e18 #define ub upper_bound #define lb lower_bound #define bs binary_search #define eb emplace_back const double pi = acos(-1); ll binpow(ll a, ll b){ll res=1;while(b!=0){if(b&1)res*=a;a*=a;b>>=1;}return res;} ll binpow(ll a, ll b, ll md){ll res=1;a%=md;if(a==0)return 0;while(b!=0){if(b&1)res*=a,res%=md;a*=a,a%=md;b>>=1;}return res%md;} using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("xortransform.in","r",stdin); // freopen("xortransform.out","w",stdout); // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif int z=1; // cin>>z; f(i,1,z+1) { //cout<<"Case #"<<i<<": "; ll n,m; cin>>n>>m; vector<ll> a(n),b(m),rem(1<<m),cnt(1<<m); f(i,0,n) cin>>a[i]; f(i,0,m) cin>>b[i]; bool flag=0; f(mask,0,(1<<m)) { f(i,0,m) { if(mask&(1<<i)) { ll nmask=(mask^(1<<i)); ll cur=rem[nmask]+b[i]; if(cur==a[cnt[nmask]]) rem[mask]=0,cnt[mask]=1+cnt[nmask]; else if(cnt[nmask]>=cnt[mask]) cnt[mask]=cnt[nmask],rem[mask]=cur; } if(cnt[mask]==n) { flag=1; break; } } if(flag) break; } if(flag) 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...