제출 #758643

#제출 시각아이디문제언어결과실행 시간메모리
758643KN200711은행 (IZhO14_bank)C++14
100 / 100
191 ms12572 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); sort(A.begin(), A.end()); 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; }

컴파일 시 표준 에러 (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...