Submission #926152

#TimeUsernameProblemLanguageResultExecution timeMemory
926152haru09Bank (IZhO14_bank)C++17
100 / 100
104 ms8788 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define bit(mask,i) (((mask)>>(i))&1) #define task "code" const int ar=1e5+5; const ll mod=1e9+7; int n,m; int a[21]; int b[21]; int need[(1<<20)]; int Left[(1<<20)]; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin>>n>>m; for (int i=1;i<=n;i++) { cin>>a[i]; } for (int i=1;i<=m;i++) { cin>>b[i]; } need[0]=1; Left[0]=0; for (int mask=1;mask<(1<<m);mask++) { for (int i=0;i<m;i++) { if (bit(mask,i)) { int premask=mask^(1<<i); if (need[premask]) { int target=a[need[premask]]; int money=b[i+1]+Left[premask]; if (money<target) { need[mask]=need[premask]; Left[mask]=money; } else if (money==target) { need[mask]=need[premask]+1; Left[mask]=0; } } } } if (need[mask]==n+1) return cout<<"YES",0; } cout<<"NO"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         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...