제출 #843831

#제출 시각아이디문제언어결과실행 시간메모리
843831Elvin_Fritl은행 (IZhO14_bank)C++17
71 / 100
1058 ms500 KiB
#include <bits/stdc++.h> using namespace std; const int N = 25; vector<int>a(N),b(N); int n,m; bool func(int ind,int x){ ///cerr << ind << " " << x << endl; if(ind == n){ return true; } if(x == (1<<m)){ return false; } vector<int>next; for(int i=0;i<m;i++){ if((x&(1<<i)) == 0){ next.push_back(i); } } ///cerr << next.size() << endl; bool as = false; for(int mask=1;mask<(1<<(next.size()));mask++){ if(as == true){ break; } int sum = 0,z = x; for(int i=0;i<next.size();i++){ if(mask&(1<<i)){ ///cerr << 1; sum += b[next[i]]; z += (1<<next[i]); } else{ ///cerr << 0; } } ///cerr << endl; if(sum == a[ind]){ ///cerr << mask << endl; as |= func(ind+1,z); } } return as; } int32_t main() { cin>>n>>m; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; } bool res = func(0,0); if(res == true){ cout<<"YES\n"; } else{ cout<<"NO\n"; } return 0; } /* 1 1 2 2 3 3 4 4 1 */

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

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