Submission #1089194

#TimeUsernameProblemLanguageResultExecution timeMemory
1089194vjudge1Bank (IZhO14_bank)C++17
44 / 100
66 ms604 KiB
#include <bits/stdc++.h> //qwerty47924692 using namespace std; using ll = long long; #define f first #define s second const ll N=3e5+29; ll n,m,a[N],b[N],ans,p[N]; void f(ll x,ll sum){ if(x==m){ if(sum==a[1])ans=1; return; } x++; f(x,sum+b[x]); f(x,sum); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; for(ll i=1;i<=n;i++){ cin>>a[i]; } for(ll i=1;i<=m;i++){ cin>>b[i]; p[i]=i; } if(m<=10){ do{ ll j=0; bool ch=1; for(ll i=1;i<=n;i++){ ll sum=0; while(sum<a[i]&&j<m){ sum+=b[p[++j]]; } if(sum!=a[i])ch=0; } if(ch){ cout<<"YES"; return 0; } }while(next_permutation(p+1,p+1+m)); cout<<"NO"; return 0; } f(0,0); cout<<(ans ? "YES" : "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...