Submission #839209

#TimeUsernameProblemLanguageResultExecution timeMemory
839209AlfraganusBank (IZhO14_bank)C++17
100 / 100
119 ms16768 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define printmp(a) for(auto x : a) cout << x.first << ' ' << x.second << endl; signed main(){ int n, m; cin >> n >> m; vector<int> b(n); for (int i = 0; i < n; i++) cin >> b[i]; // debt vector<int> a(m); for(int i = 0; i < m; i ++) cin >> a[i]; // tenges vector<pair<int, int>> dp((1 << m) + 1); for(int i = 0; i <= (1 << m); i ++){ pair<int, int> best = {0, 0}; for(int j = 0; j < m; j ++){ if((i & (1 << j)) == (1 << j)){ if(b[dp[i ^ (1 << j)].first] - dp[i ^ (1 << j)].second > a[j]) best = max(best, {dp[i ^ (1 << j)].first, dp[i ^ (1 << j)].second + a[j]}); if (b[dp[i ^ (1 << j)].first] - dp[i ^ (1 << j)].second == a[j]) best = max(best, {dp[i ^ (1 << j)].first + 1, 0}); } } if(best.first == n){ cout << "YES"; return 0; } dp[i] = best; } cout << "NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...