Submission #637234

#TimeUsernameProblemLanguageResultExecution timeMemory
637234bonkBank (IZhO14_bank)C++14
71 / 100
1095 ms8260 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20002; vector<int>v[N]; vector<int>a, b; vector<int>bit(21); bool tmp = false; int n, m; bool check(int idx){ if(idx >= n || tmp) return true; for(int i = 0; i < v[a[idx]].size(); i++){ bool ok = true; for(int j = 0; j < 21; j++){ if((v[a[idx]][i]>>j)&1){ if(bit[j]) ok = false; bit[j]++; } } if(ok) tmp |= check(idx + 1); for(int j = 0; j < 21; j++){ if((v[a[idx]][i]>>j)&1) bit[j]--; } } return tmp; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; a.resize(n); b.resize(m); for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; int all = (1<<m); for(int mask = 1; mask < all; mask++){ int sum = 0; for(int i = 0; i < m; i++){ if((mask>>i)&1) sum += b[i]; } v[sum].push_back(mask); } if(check(0)) cout << "YES" << '\n'; else cout << "NO" << '\n'; return 0; }

Compilation message (stderr)

bank.cpp: In function 'bool check(int)':
bank.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < v[a[idx]].size(); 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...