# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
851217 | NamPE | Bank (IZhO14_bank) | C++17 | 107 ms | 17068 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a(n), b(m);
for (ll& i : a) {
cin >> i;
}
for (ll& i : b) {
cin >> i;
}
vector<ll> covered(1 << m, -1), leftover(1 << m, -1);
covered[0] = leftover[0] = 0;
for (ll i = 0; i < covered.size(); i++) {
for (ll j = 0; j < m; j++) {
if (!(i & (1 << j))) {
continue;
}
ll prev = i ^ (1 << j);
if (covered[prev] == -1) {
continue;
}
ll total = leftover[prev] + b[j];
ll salary = a[covered[prev]];
if (total == salary) {
covered[i] = covered[prev] + 1;
leftover[i] = 0;
} else if (total < salary) {
covered[i] = covered[prev];
leftover[i] = total;
}
}
if(covered[i] == n) {
cout << "YES";
return 0;
}
}
cout << "NO";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |