Submission #1033452

#TimeUsernameProblemLanguageResultExecution timeMemory
1033452bytecode_1234Bank (IZhO14_bank)C++14
19 / 100
164 ms12636 KiB
#include<bits/stdc++.h> using namespace std; using ll=int; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,m; cin>>n>>m; vector<ll> v(n); for(ll i=0;i<n;i++) { cin>>v[i]; } vector<ll> v1(m); for(ll i=0;i<m;i++) { cin>>v1[i]; } vector<vector<ll>> dp1(n+1,vector<ll>(pow(2,m),-1)); for(ll i=0;i<pow(2,m);i++) { dp1[0][i]=0; } vector<vector<ll>> dp2(n); ll f=0; for(ll i=0;i<n;i++) { for(ll j=0;j<pow(2,m);j++) { ll sum=0; for(ll k=0;k<m;k++) { if(j&(1<<k)) { sum+=v1[k]; } } if(sum==v[i]) { dp2[i].push_back(j); } } if(dp2[i].size()==0) { f=1; break; } } for(ll i=1;i<=n;i++) { for(ll j=0;j<pow(2,m);j++) { ll sum=0; for(ll k=0;k<m;k++) { if(j&(1<<k)) { sum+=v1[k]; } } if(sum==v[i-1]) { dp1[i][j]=0; } } } if(f) { cout<<"NO"<<"\n"; } else if(n==1) { if(dp2[0].size()>0) { cout<<"YES"<<"\n"; } else { cout<<"NO"<<"\n"; } } else { vector<ll> dp(n+1,-1); dp[0]=0; ll x=pow(2,m)-1; for(ll i=1;i<=n;i++) { for(ll j=0;j<dp2[i-1].size();j++) { if((x&(dp2[i-1][j]))==dp2[i-1][j]) { if(dp1[i-1][x^(dp2[i-1][j])]==0) { dp[i]=0; break; } } } } if(dp[n]==0) { cout<<"YES"<<"\n"; } else { cout<<"NO"<<"\n"; } } }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:113:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |        for(ll j=0;j<dp2[i-1].size();j++)
      |                   ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...