| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|
| 1289376 | | ndan | 은행 (IZhO14_bank) | C++20 | | 315 ms | 221780 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define file "test"
#define forr(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define forf(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define MASK(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
const int maxn = 2e6 + 3;
const int MOD = 1e9 + 7; // 998244353 // 1e9 + 2277 // 1e9 + 5277
// const int inf = 1e18;
const int oo = 1e9 + 7;
const float eps = 1e-6;
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (x > y) {
x = y;
return true;
}
return 0;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (x < y) {
x = y;
return true;
}
return 0;
}
/* END OF TEMPLATE. WHAT A SIGMA! TAKE A DEEP BREATH AND READY FOR CODING :D */
int n, m, dp[maxn][25], a[25], b[25];
bool check[maxn][25];
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
forr(i, 1, n) cin >> a[i];
forr(i, 1, m) cin >> b[i];
memset(dp, 63, sizeof dp);
dp[0][1] = 0;
forf(mask, 0, MASK(m))
forr(i, 1, m)
if (bit(mask, i - 1))
forr(j, 1, n)
if (dp[mask ^ MASK(i - 1)][j] + b[i] <= a[j]) {
dp[mask][j] = dp[mask ^ MASK(i - 1)][j] + b[i];
if (dp[mask][j] == a[j]) {
dp[mask][j + 1] = 0;
check[mask][j] = 1;
}
}
forf(mask, 0, MASK(m))
if (check[mask][n]) {
cout << "YES";
return 0;
}
cout << "NO";
return 0;
}
| # | 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... |