Submission #576339

#TimeUsernameProblemLanguageResultExecution timeMemory
576339SpringmikeBank (IZhO14_bank)C++17
100 / 100
139 ms16820 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const ll MOD=1e9+7; pair<ll,ll>dp[2000005]; ll a[2000005],b[2000005]; void giai() { ll n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=m;i++) cin>>b[i]; dp[0].first=0; dp[0].second=0; for(int mask=1;mask<=(1<<m)-1;mask++) { for(int i=1;i<=m;i++) if(mask&(1<<(i-1))) { pair<ll,ll>num; num=dp[mask^(1<<(i-1))]; num.second+=b[i]; if(num.second==a[num.first+1]) { ++num.first; if(num.first==n) { cout<<"YES"; return; } num.second=0; } dp[mask]=max(dp[mask],num); } } cout<<"NO"<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if(fopen("CF.inp","r")) { freopen("CF.inp","r",stdin); freopen("CF.out","w",stdout); } ll t; giai(); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:53:8: warning: unused variable 't' [-Wunused-variable]
   53 |     ll t;
      |        ^
bank.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen("CF.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bank.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen("CF.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...