제출 #725871

#제출 시각아이디문제언어결과실행 시간메모리
725871AndrijaM은행 (IZhO14_bank)C++14
71 / 100
1076 ms189108 KiB
#include <bits/stdc++.h> using namespace std; int n,m; int x[23]; int y[23]; int dp[23][(1<<21)]; bool f(int idx,int mask) { if(idx==n) { return 1; } if(__builtin_popcount(mask)==m) { return 0; } if(dp[idx][mask]!=-1)return dp[idx][mask]; int rez=0; for(int i=0;i<(1<<m);i++) { int sum=0; for(int bit=0;bit<=23;bit++) { if(i&mask) { break; } else { if(i&(1<<bit)) { sum+=y[bit]; } } } if(sum==x[idx]) { int bmask=mask; bmask|=i; rez|=f(idx+1,bmask); } } return dp[idx][mask]=rez; } int main() { memset(dp,-1,sizeof dp); cin>>n>>m; for(int i=0;i<n;i++)cin>>x[i]; for(int i=0;i<m;i++)cin>>y[i]; int k=0; if(f(0,0)) { cout<<"YES"<<endl; return 0; } cout<<"NO"<<endl; return 0; }

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

bank.cpp: In function 'bool f(int, int)':
bank.cpp:46:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   46 |     return dp[idx][mask]=rez;
      |            ~~~~~~~~~~~~~^~~~
bank.cpp: In function 'int main()':
bank.cpp:55:9: warning: unused variable 'k' [-Wunused-variable]
   55 |     int k=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...