# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1006723 |
2024-06-24T07:48:08 Z |
thdh__ |
Bank (IZhO14_bank) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define pb push_back
#define eb emplace_back
#define pu push
#define ins insert
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff(x,a,b,c) for (auto x=a;x<=b;x+=c)
#define fd(x,a,b,c) for (auto x=a;x>=b;x-=c)
#define int ll
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;}
pair<int,int> dp[(1<<20)+1];
void solve()
{
int n,m;
cin>>n>>m;
vector<int> a(n),b(m);
for (int i=0;i<n;i++) cin>>a[i];
for (int j=0;j<m;j++) cin>>b[j];
dp[0] = {0,n};
bool check[1<<m] {false}; check[0] = true;
for (int mask=0;mask<(1<<m);mask++)
{
for (int i=0;i<m;i++)
{
if (mask & (1<<i) && check[mask ^ (1<<i)])
{
int nmask = mask ^ (1<<i);
int cur = dp[nmask].second+b[i];
if (cur==a[dp[nmask].first]) dp[mask] = {dp[nmask].first+1,0}, check[mask] = true;
else if (cur<a[dp[nmask].first]) dp[mask] = {dp[nmask].first,cur},check[mask] = true;
}
}
if (dp[mask].first==n)
{
cout<<"YES"; return;
}
}
cout<<"NO";
}
signed main()
{
bruh
int t = 1;
//cin>>t;
while (t--)
{
solve();
cout<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |