Submission #758642

#TimeUsernameProblemLanguageResultExecution timeMemory
758642KN200711Bank (IZhO14_bank)C++14
71 / 100
1091 ms44716 KiB
# include <bits/stdc++.h> using namespace std; map<int, vector<int> > ck; int nd[1000001]; set<int> dp[21]; int main() { int N, M; scanf("%d %d", &N, &M); vector<int> A(N), B(M); int sum1 = 0, sum2 = 0; for(int i=0;i<N;i++) { scanf("%d", &A[i]); nd[A[i]] = 1; sum1 += A[i]; } for(int i=0;i<M;i++) { scanf("%d", &B[i]); sum2 += B[i]; } if(sum1 > sum2) { printf("NO\n"); return 0; } for(int i=0;i<(1 << M);i++) { int sum = 0; for(int k=0;k<M;k++) { if(i&(1 << k)) sum += B[k]; } if(sum <= 1e6 && nd[sum]) ck[sum].push_back(i); } dp[0].insert(0); for(int i=0;i<N;i++) { for(auto p : dp[i]) { for(auto k : ck[A[i]]) { if(p&k) continue; dp[i + 1].insert(p|k); } } } if(dp[N].size()) printf("YES\n"); else printf("NO\n"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d %d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &A[i]);
      |   ~~~~~^~~~~~~~~~~~~
bank.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   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...