제출 #1082303

#제출 시각아이디문제언어결과실행 시간메모리
1082303Malix은행 (IZhO14_bank)C++14
19 / 100
76 ms16776 KiB
#include <bits/stdc++.h> using namespace std; #define REP(a,b,c) for(int a=b;a<c;a++) #define F first #define S second #define PB push_back #define LSOne(s) ((s)&(-s)) typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<ll,int> pi; typedef vector<pi> pii; ll M=1000000007; ll INF=1000000000000000010; int inf=1000000010; int n,m; vi a,b; int main(){ cin>>n>>m; a.resize(n);b.resize(m); REP(i,0,n)cin>>a[i]; REP(i,0,m)cin>>b[i]; int k=pow(2,m); pii dp(k+1,{-1,-1}); dp[0]={0,0}; REP(i,1,k+1){ REP(j,0,m)if(i&(1<<j)){ int ps=i^(1<<j); if(dp[ps].F==-1)continue; if(dp[ps].S+b[j]==a[dp[ps].F]){ dp[i].F=dp[ps].F+1; dp[i].S=0; } else{ dp[i].F=dp[ps].F; dp[i].S=dp[ps].S+b[j]; } } if(dp[i].F==n){ cout<<"YES\n"; return 0; } } cout<<"NO\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...