제출 #1058269

#제출 시각아이디문제언어결과실행 시간메모리
1058269vjudge1은행 (IZhO14_bank)C++17
100 / 100
71 ms14780 KiB
#include<bits/stdc++.h> #define ii pair<int,int> using namespace std; int n ,m, a[22],b[22],d[(1<<20)+2]; ii f[(1<<22)]; main () { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); 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}; d[0]=1; for(int mask = 1 ;mask<(1<<m);mask++) for(int i = 0 ;i<m;i++) if(mask>>i&1) if(d[mask^(1<<i)]) { ii tmp = f[mask^(1<<i)]; tmp.second+=b[i]; if(tmp.second<a[tmp.first]) { f[mask]=tmp; d[mask]=1; } else if(tmp.second==a[tmp.first]) { f[mask]={tmp.first+1,0}; d[mask]=1; } } for(int i =1 ;i<(1<<m);i++) if(f[i].first>n) { cout<<"YES"; return 0; } cout<<"NO"; }

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

bank.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main ()
      | ^~~~
bank.cpp: In function 'int main()':
bank.cpp:33:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |   for(int i =1 ;i<(1<<m);i++)
      |   ^~~
bank.cpp:39:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |    cout<<"NO";
      |    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...