제출 #1006723

#제출 시각아이디문제언어결과실행 시간메모리
1006723thdh__은행 (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...