Submission #1089278

#TimeUsernameProblemLanguageResultExecution timeMemory
1089278vjudge1Bank (IZhO14_bank)C++17
19 / 100
6 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],used[N],total[N]; void f(ll x,ll sum,ll i){ if(x==m){ if(sum==a[i]&&i<n){ for(ll i=1;i<=m;i++)total[i]^=used[i]; f(0,0,i+1); for(ll i=1;i<=m;i++)total[i]^=used[i]; } if(i==n&&sum==a[n]){ ans=1; // for(ll i=1;i<=m;i++)cout<<used[i]<<' '; return; } return; } x++; if(!total[i])used[x]=1; if(!total[i]&&sum<b[x]<=a[i])f(x,sum+b[x],i); used[x]=0; f(x,sum,i); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; if(n>m){ cout<<"NO"; return 0; } for(ll i=1;i<=n;i++){ cin>>a[i]; } for(ll i=1;i<=m;i++){ cin>>b[i]; p[i]=i; } f(0,0,1); cout<<(ans ? "YES" : "NO"); }

Compilation message (stderr)

bank.cpp: In function 'void first(ll, ll, ll)':
bank.cpp:25:22: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
   25 |     if(!total[i]&&sum<b[x]<=a[i])f(x,sum+b[x],i);
      |                   ~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...