Submission #640100

#TimeUsernameProblemLanguageResultExecution timeMemory
640100bonkBank (IZhO14_bank)C++14
19 / 100
104 ms89420 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20002; vector<int>v[N]; vector<int>a(21), b(21); vector<int>bit(21); int dp[20][(1<<20) + 1]; int n, m; bool f(int idx, int mask){ if(idx >= n) return 1; auto &cur = dp[idx][mask]; if(cur != -1) return cur; cur = 0; for(int i = 0; i < v[a[idx]].size(); i++){ if(!(mask & v[a[idx]][i])) cur = f(idx + 1, mask | v[a[idx]][i]); } return cur; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(dp, -1, sizeof(dp)); cin >> n >> 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(f(0, 0)) cout << "YES" << '\n'; else cout << "NO" << '\n'; return 0; }

Compilation message (stderr)

bank.cpp: In function 'bool f(int, int)':
bank.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     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...