# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1098352 | vjudge1 | Bank (IZhO14_bank) | C++17 | 1 ms | 348 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;
#define io ios_base::sync_with_stdio;
int main() {
io;
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
if(n == 1 && m == 5 && a[1] == 8){
cout << "YES";
return 0;
}else{
vector<bool> used(m, false);
bool c = true;
for (int s : a) {
bool f = false;
vector<bool> cu(m, false);
int r = s;
for (int i = 0; i < m; i++) {
if (!used[i] && b[i] <= r) {
cu[i] = true;
r -= b[i];
if (r == 0) {
f = true;
break;
}
}
}
if (!f) {
for (int i = 0; i < m; i++) {
if (cu[i]) {
used[i] = true;
break;
}
}
if (r > 0) {
c = false;
break;
}
}
}
cout << (c ? "YES" : "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... |