제출 #378477

#제출 시각아이디문제언어결과실행 시간메모리
378477Ahmad_Hasan은행 (IZhO14_bank)C++17
100 / 100
435 ms211948 KiB
#include <bits/stdc++.h> /** |||||||||| ||||||||| |||||||||||| ||||| ||||| |||| |||| ||||| ||||| |||||||||||| ||||| ||||| |||||||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||||||| PLATINUM OVERFLOW; */ ///#define int long long using namespace std; vector<int>subs[1000+5],v1,v2; int n,m; int dp[20+5][(1<<21)]; bool slv(int idx=0,int msk=0){ ///cout<<idx<<' '<<msk<<'\n'; if(idx==n) return true; if(dp[idx][msk]!=-1){ return dp[idx][msk]; } bool ret=false; for(int i=0;i<subs[v1[idx]].size();i++){ if(!(msk&subs[v1[idx]][i])){ ret=max(ret,slv(idx+1,msk|subs[v1[idx]][i])); } if(ret) return dp[idx][msk]=ret; } return dp[idx][msk]=ret; } int32_t main() {/** freopen("arb2.in","r",stdin); freopen("arb2.out","w",stdout);*/ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; v1=vector<int>(n); v2=vector<int>(m); for(int i=0;i<n;i++) cin>>v1[i]; for(int i=0;i<m;i++) cin>>v2[i]; for(int i=1;i<(1<<m);i++){ int sum=0; for(int j=0;j<m;j++){ if((1<<j)&i) sum+=v2[j]; } if(sum<=1000) subs[sum].push_back(i); } memset(dp,-1,sizeof(dp)); if(slv()) cout<<"YES"<<'\n'; else cout<<"NO"<<'\n'; return 0; } /** 1 8 2 abczzzzz */

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

bank.cpp: In function 'bool slv(int, int)':
bank.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<subs[v1[idx]].size();i++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:32:32: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   32 |             return dp[idx][msk]=ret;
      |                    ~~~~~~~~~~~~^~~~
bank.cpp:34:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   34 |     return dp[idx][msk]=ret;
      |            ~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...