Submission #908789

#TimeUsernameProblemLanguageResultExecution timeMemory
908789khachatur25Bank (IZhO14_bank)C++14
100 / 100
112 ms8792 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> v(n); vector<int> vc(m); for (auto& elem : v) cin >> elem; for (auto& elem : vc) cin >> elem; vector<int> dzaxot(1 << m, -1); vector<int> mardik(1 << m, -1); dzaxot[0] = 0; mardik[0] = 0; for (int s = 0; s < (1 << m); s++) { for (int last = 0; last < m; last++) { if ((s & (1 << last)) == 0) continue; int prev = s & ~(1 << last); if (mardik[prev] == -1) continue; int tiv = dzaxot[prev] + vc[last]; int cel = v[mardik[prev]]; if (tiv < cel) { mardik[s] = mardik[prev]; dzaxot[s] = tiv; } else if (tiv == cel) { mardik[s] = mardik[prev] + 1; dzaxot[s] = 0; } } if (mardik[s] == n) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...