| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307208 | pete555 | Bank (IZhO14_bank) | C++17 | 100 ms | 8604 KiB |
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
const int INF = 10000;
int main()
{
cin.tie(0)->sync_with_stdio(false);
//fileIO("");
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> b(m);
for (int i = 0; i < m; i++) {
cin >> b[i];
}
vector<pi> dp(1 << m);
dp[0] = {0, 0};
for (int s = 1; s < (1 << m); s++) {
dp[s] = {-1, -1};
for (int i = 0; i < m; i++) {
if (s & (1 << i)) {
pi prev = dp[s ^ (1 << i)];
if(prev.first == -1) continue;
if(prev.second + b[i] == a[prev.first]) {
prev.first++;
prev.second = 0;
dp[s] = max(dp[s], prev);
}
else if(prev.second + b[i] < a[prev.first]) {
prev.second += b[i];
dp[s] = max(dp[s], prev);
}
}
}
if (dp[s].first == n) {
cout << "YES" << '\n';
return 0;
}
}
cout << "NO" << '\n';
}
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... | ||||
