제출 #1056507

#제출 시각아이디문제언어결과실행 시간메모리
1056507vjudge1은행 (IZhO14_bank)C++17
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); 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=1;i<m;++i){ if(!on(mask,i))continue; if(k[ex(mask,i)]){ ii res=f[ex(mask,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}; } } } } } for(int i=1;i<(1<<m);++i){ if(f[i].fi>n){ cout<<"YES"; return 0; } } cout <<"NO"; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...