# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988239 | Tsagana | Bank (IZhO14_bank) | C++14 | 1048 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>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
bool rep(int l, int x, vector<int> a, vector<int> b) {
if (!x) {
l++;
if (l < a.size()) x = a[l];
else return 1;
}
for (int i = 0; i < b.size(); i++) {
if (b[i] > x) continue ;
int k = b[i]; b[i] = 2000;
if (rep(l, x - k, a, b)) return 1;
b[i] = k;
}
return 0;
}
void solve () {
vector<int> a, b;
int n, m; cin >> n >> m;
a.resize(n); b.resize(m);
for (int &i: a) cin >> i;
for (int &i: b) cin >> i;
sort(all(a)); sort(all(b));
while (!b.empty() && b.back() > a.back()) b.pp();
cout << (rep(0, a[0], a, b) ? "YES" : "NO");
}
signed main() {IOS solve(); return 0;}
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... |