Submission #880932

#TimeUsernameProblemLanguageResultExecution timeMemory
880932Younis_DwaiBank (IZhO14_bank)C++14
0 / 100
68 ms262144 KiB
#include <bits/stdc++.h> #define int long long #define in insert #define F first #define S second #define pb push_back #define endl "\n" //#define mid (l+r)/2 #define all(v) v.begin(),v.end() //#define pop pop_back using namespace std; const int M=1e9+7; int n,m; int a[25],b[25]; int dp[24][3000009]; vector<int> adj[200009]; bool rec(int id , int mask){ if(dp[id][mask]!=-1) return dp[id][mask]; else if(id==n) return 1; bool c=0; for(auto u : adj[a[id]]){ if((mask&u)) continue ; c=max(c,rec(id+1,(mask|u))); if(c==1) break; } return dp[id][mask]=c; } int32_t main(){ freopen("stdin","r",stdin); freopen("stdout","w",stdout); ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); memset(dp,-1,sizeof dp); cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<m;i++) cin>>b[i]; for(int mask=1;mask<(1<<m);mask++){ int sum=0; for(int i=0;i<m;i++){ if((mask&(1<<i))) sum+=b[i]; } adj[sum].pb(mask); } if(rec(0,0)==1) cout<<"YES"; else cout<<"NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'bool rec(long long int, long long int)':
bank.cpp:26:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   26 |     return dp[id][mask]=c;
      |            ~~~~~~~~~~~~^~
bank.cpp: In function 'int32_t main()':
bank.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen("stdin","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
bank.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("stdout","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...