| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1281797 | quan606303 | Bank (IZhO14_bank) | C++20 | 1096 ms | 984 KiB |
/*
* @Author: RMQuan
* @Date: 2025-10-22 10:47:26
* @Last Modified by: RMQuan
* @Last Modified time: 2025-10-22 11:06:11
*/
/*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 "TEST"
#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];
vector<int> adj[1005];
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];
for (int mask=0;mask<(1<<m);mask++)
{
int sum=0;
for (int i=0;i<mask;i++)if(mask&(1<<i))sum+=b[i];
if (sum<=1000)adj[sum].push_back(mask);
}
dp[0][0]=1;
for (int i=1;i<=n;i++)
{
for (int premask=0;premask<(1<<m);premask++)
{
if (dp[i-1][premask])
{
for (auto mask:adj[a[i]])if ((premask&mask)==0)dp[i][mask]=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... | ||||
