Submission #1056579

#TimeUsernameProblemLanguageResultExecution timeMemory
1056579vjudge1Bank (IZhO14_bank)C++14
0 / 100
1 ms4444 KiB
#include<bits/stdc++.h> #define int long long #define emb emplace_back #define ii pair<int,int> #define fi first #define se second using namespace std; const int N=21+5,mod=1e9+7; int n,M[N],ans,m,a[N],b[N]; bool k[(1<<21)+5]; ii f[(1<<21)+5]; bool on(int mask,int i){ return (mask>>1)&1; } int ex(int mask,int i){ return mask^(1<<i); } main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if(fopen("bank.in","r")){ freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); } cin >> n >> m; for(int i=1;i<=n;++i)cin >> a[i]; for(int i=0;i<m;++i)cin >> b[i]; f[0]={1,0}; k[0]=1; for(int mask=1;mask<(1<<m);++mask){ for(int i=0;i<m;++i){ if(!on(mask,i))continue; if(k[mask^(1<<i)]){ ii res=f[mask^(1<<i)]; res.se+=b[i]; if(res.se<a[res.fi]){ k[mask]=true; f[mask]=res; } else{ if(res.se==a[res.fi]){ k[mask]=true; f[mask]={res.fi+1,0}; } } //cout<<i<<'\n'; } } } for(int i=1;i<(1<<m);++i){ if(f[i].fi>n){ cout<<"YES"; return 0; } } cout <<"NO"; }

Compilation message (stderr)

bank.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
bank.cpp: In function 'int main()':
bank.cpp:26:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |       freopen("bank.in","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:27:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |       freopen("bank.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...