Submission #637988

#TimeUsernameProblemLanguageResultExecution timeMemory
637988kakayoshiBank (IZhO14_bank)C++14
27 / 100
19 ms3516 KiB
#include <bits/stdc++.h> using namespace std; #define forw(i,a,b) for(ll i=a;i<=b;i++) #define forb(i,a,b) for(ll i=a;i>=b;i--) #define fi first #define se second #define pb push_back #define pu push #define all(a) a.begin(),a.end() #define getbit(mask,i) ((mask>>(i))&1) #define getnum(i) (1<<(i)) #define add(a,b) (a)=((a)+(b))%mod #define minimize(a,b) (a)=min((a),(b)) typedef long long int ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll maxN=1e5+5; const ll mod=1e9+7; const ll oo=1e18; const int tx[2]={0,1}; const int ty[2]={1,0}; ll n,m,a[22],b[22],dp[maxN],sum[maxN]; void solve() { cin>>n>>m; forw(i,1,n) cin>>a[i]; forw(i,1,m) cin>>b[i]; forw(mask,1,(1<<m)-1) forw(i,1,m) if (mask>>(i-1)&1) sum[mask]+=b[i]; forw(mask1,1,(1<<m)-1) for(int mask2=mask1;mask2;mask2=((mask2-1)&mask1)) if (sum[mask2]==a[dp[mask1^mask2]+1]) dp[mask1]=max(dp[mask1],dp[mask1^mask2]+1); if (dp[(1<<m)-1]==n) cout<<"YES"; else cout<<"NO"; return; } int main() { ios::sync_with_stdio(0); cin.tie(0); //freopen("bruh.inp","r",stdin); //freopen("bruh.out","w",stdout); int t=1; //cin>>t; while(t--) solve(); 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...