제출 #908786

#제출 시각아이디문제언어결과실행 시간메모리
908786khachatur25은행 (IZhO14_bank)C++14
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...