Submission #382549

#TimeUsernameProblemLanguageResultExecution timeMemory
382549mariowongBank (IZhO14_bank)C++14
0 / 100
2 ms364 KiB
#include <bits/stdc++.h> using namespace std; int m,n,a[25],b[25],val[1100000]; vector <int> v,ps[25],v2; bool dp[25][1100000]; int main(){ ios::sync_with_stdio(false); cin >> n >> m; for (int i=1;i<=n;i++){ cin >> a[i]; } for (int i=0;i<m;i++){ cin >> b[i]; } for (int i=0;i<(1<<m);i++){ for (int j=0;j<m;j++){ if (i&(1<<j) > 0) val[i]+=b[j]; } for (int j=1;j<=n;j++){ if (val[i] == a[j]) ps[j].push_back(i); } } v.push_back(0); for (int i=1;i<=n;i++){ v2.clear(); if (v.size() == 0){ cout << "NO\n"; return 0; } for (int j=0;j<ps[i].size();j++){ for (int k=0;k<v.size();k++){ if (v[j]&ps[i][j] == 0) v2.push_back(v[j]|ps[i][j]); } } v.clear(); v=v2; } cout << "YES\n"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:18:17: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   18 |    if (i&(1<<j) > 0)
      |          ~~~~~~~^~~
bank.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int j=0;j<ps[i].size();j++){
      |                ~^~~~~~~~~~~~~
bank.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for (int k=0;k<v.size();k++){
      |                 ~^~~~~~~~~
bank.cpp:35:23: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   35 |     if (v[j]&ps[i][j] == 0)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...