제출 #880142

#제출 시각아이디문제언어결과실행 시간메모리
880142boris_7은행 (IZhO14_bank)C++17
100 / 100
390 ms6996 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; void solve(){ int n,m; cin>>n>>m; vector<int>a(n); vector<int>b(m); for(int &i:a){ cin>>i; } for(int &i:b){ cin>>i; } vector<vector<int>>sum(1001); for(int i = 0;i<(1<<m);i++){ int gumar = 0; for(int j = 0;j<m;j++){ if(i&(1<<j)){ gumar+=b[j]; } } if(gumar<=1000){ sum[gumar].push_back(i); } } vector<bool>last((1<<m)+1),cur((1<<m)+1); for(int i = 0;i<int(sum[a[0]].size());i++){ last[sum[a[0]][i]]=1; } for(int i = 1;i<n;i++){ for(int j = 0;j<(1<<m);j++){ if(last[j]==0) continue; for(int &k:sum[a[i]]){ if((k&j)==0){ cur[j+k]=1; } } } for(int c = 0;c<cur.size();c++){ last[c]=cur[c]; cur[c]=0; } } int ans = 0; for(bool i:last){ ans |= int(i); } if(ans){ cout<<"YES"; } else{ cout<<"NO"; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); // ll t;cin>>t;while(t--) solve(); }

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

bank.cpp: In function 'void solve()':
bank.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int c = 0;c<cur.size();c++){
      |                       ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...