Submission #1033433

#TimeUsernameProblemLanguageResultExecution timeMemory
1033433bytecode_1234Bank (IZhO14_bank)C++14
0 / 100
2 ms604 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 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); 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"<<"\n"; } else if(n==1) { if(dp1.size()>0) { cout<<"YES"<<"\n"; } else { cout<<"NO"<<"\n"; } } 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"<<"\n"; } else { cout<<"NO"<<"\n"; } } }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:91: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]
   91 |         for(ll k=0;k<dp1[i-1].size();k++)
      |                    ~^~~~~~~~~~~~~~~~
bank.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...