제출 #1068460

#제출 시각아이디문제언어결과실행 시간메모리
1068460vjudge1은행 (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define ff first #define ss second #define pb push_back vector<int>v[20]; int n; bool calc(int msk=0, int cur=0){ if(cur==n) return 1; bool res=0; for(int i=0; i<v[cur].size(); i++){ if(__builtin_popcount(v[cur][i]|msk)==__builtin_popcount(msk)+__builtin_popcount(v[cur][i])){ res|=calc(v[cur][i]|msk,cur+1); } } return res; } void solve(){ int m; cin>>n>>m; int a[n],b[m]; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<m; i++) cin>>b[i]; sort(b,b+m); for(int i=0; i<n; i++){ for(int j=1; j<(1<<m); j++){ int sum=0; for(int k=0; k<m; k++) if((1<<k)&j) sum+=b[k]; if(sum>a[i]) break; if(sum==a[i]) v[i].pb(j); } } if(calc()) cout<<"YES"; else cout<<"NO"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; // cin>>t; for(int _=0; _<t; _++){ // cout<<"Case "<<_+1<<":\n"; solve(); } return 0; } //080129552180

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

bank.cpp: In function 'bool calc(int, int)':
bank.cpp:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0; i<v[cur].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...