Submission #908788

#TimeUsernameProblemLanguageResultExecution timeMemory
908788khachatur25Bank (IZhO14_bank)C++17
0 / 100
2 ms348 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 (int i = 0;i < n;i++)cin >> v[i]; for (int i = 0;i < n;i++)cin >> vc[i]; 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...