# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056090 | vjudge1 | Bank (IZhO14_bank) | C++17 | 81 ms | 11696 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 se second
#define fi first
const int Nmax = 1e6 + 207;
const int LogN = 17;
int n , m;
int a[30] , b[30];
bool c[1 << 21];
pair <int , int> dp[1 << 21];
main()
{
cin >> n >> m;
for (int i = 1 ; i <= n ; i++)
cin >> a[i];
for (int i = 0 ; i < m ; i++)
cin >> b[i];
c[0] = true;
dp[0] = {1 , 0};
for (int mask = 1 ; mask < (1 << m ) ; mask++)
{
for (int i = 0 ; i < m; i++)
{
if (mask & (1 << i))
{
if (c[mask ^ (1 << i)])
{
pair <int , int> tmp = dp[mask ^ (1 << i)];
tmp.se += b[i];
if (tmp.se < a[tmp.fi])
{
c[mask] = true;
dp[mask] = tmp;
}
else if (tmp.se == a[tmp.fi])
{
c[mask] = true;
dp[mask] = {tmp.fi + 1 , 0};
}
}
}
}
}
bool v = false;
for (int mask = 1 ; mask < (1 << m) ; mask++)
if (dp[mask].fi > n)
{
cout << "YES";
return 0;
}
cout << "NO" << endl;
}
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... |