Submission #1082839

#TimeUsernameProblemLanguageResultExecution timeMemory
1082839elotelo966Bank (IZhO14_bank)C++17
0 / 100
163 ms261732 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define OYY LLONG_MAX #define mod 998244353 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 1005 #define fi first #define se second int n,m; int a[lim],b[lim]; int dp[(1<<14)][lim]; inline int f(int mask,int sum){ if(mask==(1<<m)-1)return 0; if(~dp[mask][sum])return dp[mask][sum]; int cev=0; for(int i=0;i<m;i++){ if(mask&(1<<i))continue; cev=max(cev,f(mask|(1<<i),sum+b[i])+((sum+b[i]==a[f(mask|(1<<i),sum+b[i])])?1:0)); } return dp[mask][sum]=cev; } int32_t main(){ faster memset(dp,-1,sizeof(dp)); cin>>n>>m; FOR{ cin>>a[i-1]; } for(int i=0;i<m;i++)cin>>b[i]; int cev=f(0,0); //cout<<cev<<endl; if(cev==n)cout<<"YES"<<'\n'; else cout<<"NO"<<'\n'; 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...