# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039863 | lmaobruh | Bank (IZhO14_bank) | C++14 | 92 ms | 93016 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.
// 027 072 207 270 702 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define fo(i, a, b) for (int i = (a), b_ = (b); i <= b_; ++i)
#define fod(i, a, b) for (int i = (a), b_ = (b); i >= b_; --i)
#define rep(i, n) fo(i, 1, n)
#define per(i, n) fod(i, n, 1)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
const int N = 1e6+5;
int n, m, a[N], b[N], dp[22][1<<20];
void sol() {
cin >> n >> m;
rep(i, n) cin >> a[i];
fo(i, 0, m-1) cin >> b[i];
memset(dp, -1, sizeof dp);
dp[1][0] = 0;
for (int i = 1; i <= n; ++i)
for (int mask = 0; mask < (1<<m); ++mask)
if (dp[i][mask] != -1) {
for (int j = 0; j < m; ++j) if (!(mask>>j&1)) {
if (dp[i][mask] + b[j] <= a[i]) {
dp[i][mask^(1<<j)] = dp[i][mask] + b[j];
// if (mask == 4 && i == 1) dbg(j, b[j], dp[i][mask], mask^(1<<j), dp[i][mask]+b[j]);
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... |