Submission #464581

#TimeUsernameProblemLanguageResultExecution timeMemory
464581phungminhvuBank (IZhO14_bank)C++11
100 / 100
125 ms8588 KiB
//╔═════════════════╗ //╠═════════════════╣ //╠═════════════════╣ //╚═════════════════╝ #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define nl "\n" #define ll long long #define st first #define nd second #define PII pair<int,int> //#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> using namespace std; //using namespace __gnu_pbds; void input() { #define task "name" if(fopen("CVP.inp","r")){ freopen("CVP.inp","r",stdin); freopen("CVP.out","w",stdout); } else if(fopen("CVP.in","r")){ freopen("CVP.in","r",stdin); freopen("CVP.out","w",stdout); } else if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } else if(fopen(task".in","r")){ freopen(task".in","r",stdin); freopen(task".out","w",stdout); } } void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); cin.exceptions(cin.failbit); } //#define int ll //const ll oo=4557430888798830399; const int oo=1061109567; const int maxn=20+5; const int mod=1e9+7; //const double pi=atan2(0,-1); int n,m,a[maxn],b[maxn]; PII dp[1<<20]; int32_t main() { input(); fastio(); cin>>n>>m; for(int i=0;i<n;++i) cin>>a[i]; for(int i=0;i<m;++i) cin>>b[i]; for(int mask=0;mask<(1<<m);++mask){ for(int i=0;i<m;++i){ if(mask&(1<<i)){ PII p=dp[mask^(1<<i)]; if(p.nd+b[i]==a[p.st]) dp[mask]=max(dp[mask],{p.st+1,0}); else dp[mask]=max(dp[mask],{p.st,p.nd+b[i]}); } } } if(dp[(1<<m)-1].st==n) cout<<"YES"; else cout<<"NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'void input()':
bank.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen("CVP.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen("CVP.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen("CVP.in","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bank.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("CVP.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen(task".in","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(task".out","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...