Submission #894490

#TimeUsernameProblemLanguageResultExecution timeMemory
894490Batorgil952Bank (IZhO14_bank)C++14
0 / 100
1073 ms416 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int N=21; int a[N], b[N]; int dp[N]; int n, m; map< int, int > M; int Rec(int k){ if(k==m+1){ M.clear(); int s=0; for(int i=1; i<=m; i++){ M[dp[i]]++; } int ind=0; for(int i=1; i<=n; i++){ if(M[a[i]]>0){ M[a[i]]--; } else ind++; } if(ind==0) return 1; return 0; } int ans=0; for(int i=k+1; i<=m; i++){ int c=dp[k]; dp[i]+=c; dp[k]=0; if(ans==0) ans=max(ans, Rec(k+1)); dp[i]-=c; dp[k]=c; } if(ans==0) ans=max(ans, Rec(k+1)); return ans; } int main(){ scanf("%d",&n); scanf("%d",&m); for(int i=1; i<=n; i++){ scanf("%d",&a[i]); } for(int i=1; i<=m; i++){ scanf("%d",&b[i]); dp[i]=b[i]; } if(Rec(1)) printf("YES\n"); else printf("NO\n"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int Rec(int)':
bank.cpp:17:7: warning: unused variable 's' [-Wunused-variable]
   17 |   int s=0;
      |       ^
bank.cpp: In function 'int main()':
bank.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
bank.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
bank.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
bank.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |   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...