Submission #1033428

#TimeUsernameProblemLanguageResultExecution timeMemory
1033428bytecode_1234Bank (IZhO14_bank)C++14
71 / 100
1075 ms33192 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif 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); 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]) { dp1[i].push_back(j); } } if(dp1[i].size()==0) { f=1; break; } } if(f) { cout<<"NO"<<endl; } else if(n==1) { if(dp1.size()>0) { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } } else { vector<vector<ll>> dp(n+1,vector<ll>(pow(2,m),-1)); for(ll i=0;i<pow(2,m);i++) { dp[0][i]=0; } for(ll i=1;i<=n;i++) { for(ll j=0;j<pow(2,m);j++) { for(ll k=0;k<dp1[i-1].size();k++) { if((j&dp1[i-1][k])==dp1[i-1][k]) { if(dp[i-1][j^(dp1[i-1][k])]==0) { dp[i][j]=0; break; } } } } } if(dp[n][pow(2,m)-1]==0) { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } } }

Compilation message (stderr)

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