제출 #637237

#제출 시각아이디문제언어결과실행 시간메모리
637237bonk은행 (IZhO14_bank)C++14
71 / 100
1089 ms8220 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20002; vector<int>v[N]; vector<int>a(21), b(21); vector<int>bit(21); bool tmp = false; int n, m; bool check(int idx){ if(idx >= n || tmp) return true; for(int i = 0; i < v[a[idx]].size(); i++){ if(tmp) break; bool ok = true; for(int j = 0; j < m; j++){ if((v[a[idx]][i]>>j)&1){ if(bit[j]) ok = false; bit[j]++; } } if(ok) tmp |= check(idx + 1); for(int j = 0; j < m; j++){ if((v[a[idx]][i]>>j)&1) bit[j]--; } } return tmp; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; int all = (1<<m); for(int mask = 1; mask < all; mask++){ int sum = 0; for(int i = 0; i < m; i++){ if((mask>>i)&1) sum += b[i]; } v[sum].push_back(mask); } if(check(0)) cout << "YES" << '\n'; else cout << "NO" << '\n'; return 0; }

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

bank.cpp: In function 'bool check(int)':
bank.cpp:15:22: 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[a[idx]].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...