Submission #879207

#TimeUsernameProblemLanguageResultExecution timeMemory
879207mahmoudbadawyBank (IZhO14_bank)C++17
100 / 100
123 ms8936 KiB
#include <bits/stdc++.h> using namespace std; const int N=21; int n,m; int a[N],b[N]; pair<int,int> dp[(1<<N)]; int main() { scanf("%d %d",&n,&m); for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=0;i<m;i++) scanf("%d",&b[i]); int ans=0; for(int i=1;i<(1<<m);i++) { for(int j=0;j<m;j++) { if((i&(1<<j))==0) continue; int prev=i^(1<<j); int curs = b[j] + dp[prev].second; int need = dp[prev].first; if(need>=n) continue; if(curs<a[need]) dp[i]=max(dp[i],make_pair(need, curs)); if(curs==a[need]) dp[i]=max(dp[i], make_pair(need+1, 0)); } ans=max(ans, dp[i].first); } puts(ans==n?"YES":"NO"); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d %d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~
bank.cpp:14:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  for(int i=0;i<n;i++) scanf("%d",&a[i]);
      |                       ~~~~~^~~~~~~~~~~~
bank.cpp:15:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  for(int i=0;i<m;i++) scanf("%d",&b[i]);
      |                       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...