Submission #337882

#TimeUsernameProblemLanguageResultExecution timeMemory
337882kutbilim_oneBank (IZhO14_bank)C++14
100 / 100
596 ms172908 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define all(x) x.begin(), x.end() #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(); int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int i = 0; i < n; i++) cin >> a[i]; for(int j = 0; j < m; j++) cin >> b[j]; int maxx = *max_element(all(a)); vector<int> pass[1 + maxx]; for(int bin = 1; bin < (1 << m); bin++){ int i = 0, sum = 0, temp = bin; while(temp){ if(temp & 1) sum += b[i]; temp >>= 1; i++; } if(sum <= maxx) pass[sum].push_back(bin); } vector< vector<int> > dp(n, vector<int> (1 << m, false)); for(int i = 0; i < pass[a[0]].size(); i++){ dp[0][pass[a[0]][i]] = true; } for(int i = 1; i < n; i++){ int good = 0; for(int bin = 0; bin < (1 << m); bin++){ if(!dp[i-1][bin]) continue; for(auto last : pass[a[i]]) if(!(last & bin)) dp[i][last|bin] = good = true; } if(!good) break; } bool ans = false; for(int i = 0; !ans && i < (1 << m); i++){ if(dp[n-1][i]) ans = true; } if(ans) cout << "YES"; else cout << "NO"; return 0; }

Compilation message (stderr)

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