Submission #476220

#TimeUsernameProblemLanguageResultExecution timeMemory
476220kkkBank (IZhO14_bank)C++17
100 / 100
342 ms172776 KiB
#include<cstring> #include<iostream> #define endl '\n' using namespace std; long long a[100], b[100], dp[(1<<20)+2][21], n, m; bool rec(long long pos,long long mask,long long num) { if(pos==n)return 1; if(dp[mask][pos]!=-1)return dp[mask][pos]; bool rez=0; for(int i=0;i<m;i++) { if((mask&(1<<i))==0) { if(b[i]<num) { rez=max(rez, rec(pos,(mask|(1<<i)),num-b[i])); } if(b[i]==num) { rez=max(rez, rec(pos+1,(mask|(1<<i)),a[pos+1])); } } } return dp[mask][pos]=rez; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long i,j; memset(dp,-1,sizeof(dp)); cin>>n>>m; for(i=0;i<n;i++)cin>>a[i]; for(i=0;i<m;i++)cin>>b[i]; if(rec(0,0,a[0]))cout<<"YES"<<endl; else cout<<"NO"<<endl; }

Compilation message (stderr)

bank.cpp: In function 'bool rec(long long int, long long int, long long int)':
bank.cpp:29:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   29 |     return dp[mask][pos]=rez;
      |            ~~~~~~~~~~~~~^~~~
bank.cpp: In function 'int main()':
bank.cpp:39:17: warning: unused variable 'j' [-Wunused-variable]
   39 |     long long i,j;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...