| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1281795 | quan606303 | 은행 (IZhO14_bank) | C++20 | 1095 ms | 816 KiB |
/*
* @Author: RMQuan
* @Date: 2025-10-22 10:47:26
* @Last Modified by: RMQuan
* @Last Modified time: 2025-10-22 11:03:07
*/
/*idea :
*/
#include <bits/stdc++.h>
bool M1;
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define TASK "BANK"
#define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
using namespace std;
const int MOD=1e9+7;
int n,m;
bool dp[25][(1<<20)+5];
int a[25],b[25];
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
file();
cin>>n>>m;
for (int i=1;i<=n;i++)cin>>a[i];
for (int i=0;i<=m;i++)cin>>b[i];
dp[0][0]=1;
for (int i=1;i<=n;i++)
{
for (int mask1=0;mask1<(1<<m);mask1++)
{
int sum=0;
for (int j=0;j<m;j++)
{
if (mask1&(1<<j))sum+=b[j];
}
if (sum==a[i])
{
for (int premask=0;premask<(1<<m);premask++)if (dp[i-1][premask]&&((premask&mask1)==0))dp[i][mask1]=true;
}
}
}
bool ans=0;
for (int mask=0;mask<(1<<m);mask++)ans|=dp[n][mask];
cout<<(ans?"YES":"NO");
bool M2;
cerr<<"-------------------------------------------------"<<endl;
cerr<<"Time : "<<clock()<<" ms"<<endl;
cerr<<"Memory : "<<abs(&M2-&M1)/1024/1024<<" MB"<<endl;
cerr<<"-------------------------------------------------"<<endl;
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... | ||||
