Submission #91097

#TimeUsernameProblemLanguageResultExecution timeMemory
91097Aydarov03Bank (IZhO14_bank)C++14
71 / 100
1083 ms8060 KiB
#include <bits/stdc++.h> using namespace std; int a[25] , b[25]; vector <int> v[20005]; int n , m; string bin(int a) { string s = ""; while( a > 0 ) { s += a % 2 + '0'; a /= 2; } while( s.size() < m )s += '0'; return s; } void rec( int id = 1 , int OR = 0) { for(auto c : v[ a[id] ] ) { if( (c & OR) == 0 ) { if( id == n ) { cout << "YES"; exit(0); } rec( id+1 , OR | c ); } } } main() { cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; for(int mask = 1; mask < (1<<m); mask++) { int sum = 0; for(int i = 0; i < m; i++) { if( mask & ( (1<<i) ) ) sum += b[i+1]; } v[sum].push_back( mask ); } for(int i = 1; i <= n; i++) { if( v[a[i]].size() == 0 ) return cout << "NO" , 0; } // // for(int i = 1; i <= n; i++) // { // cout << a[i] << endl; // for(auto c : v[ a[i] ])cout << bin(c) << endl; // } // puts("******");cout<<endl<<endl; rec(); cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'std::__cxx11::string bin(int)':
bank.cpp:16:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while( s.size() < m )s += '0';
            ~~~~~~~~~^~~
bank.cpp: At global scope:
bank.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...