Submission #1098388

#TimeUsernameProblemLanguageResultExecution timeMemory
1098388vjudge1Bank (IZhO14_bank)C++17
100 / 100
89 ms8792 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n), b(m); for(auto &i : a) { cin >> i; } for(auto &i : b) { cin >> i; } vector<int> l(1 << m, -1), r(1 << m, -1); l[0] = r[0] = 0; for(int i = 0; i < (1 << m); i++) { for(int j = 0; j < m; j++) { int k = i ^ (1 << j); if(!(i & (1 << j)) || r[k] == -1) { continue; } int w = l[k] + b[j]; int cur = a[r[k]]; if(w < cur) { r[i] = r[k]; l[i] = w; } else if(w == cur) { r[i] = r[k] + 1; l[i] = 0; } } if(r[i] == n) { cout << "YES"; return 0; } } 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...