제출 #444779

#제출 시각아이디문제언어결과실행 시간메모리
444779s_jaskaran_s은행 (IZhO14_bank)C++17
100 / 100
151 ms8644 KiB
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; int a[n],b[m]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; } vector<int> s(1<<m,-1),c(1<<m,-1); s[0]=0; c[0]=0; int z=0; for(int i=1;i<1<<m;i++){ for(int j=0;j<m;j++){ if(i&(1<<j)){ if(s[i^(1<<j)]!=-1){ int k=c[i^(1<<j)]+b[j]; if(k<a[s[i^(1<<j)]]){ c[i]=k; s[i]=s[i^(1<<j)]; } else if(k==a[s[i^(1<<j)]]){ s[i]=s[i^(1<<j)]+1; c[i]=0; } } } if(s[i]==n){ z=1; break; } } } if(z){ cout<<"YES"; } else{ cout<<"NO"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...