제출 #90469

#제출 시각아이디문제언어결과실행 시간메모리
90469xiaowuc1은행 (IZhO14_bank)C++14
100 / 100
104 ms6376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<vector<int>> matrix; int n, m; int val[20]; int bases[20]; vector<int> masks[1001]; void solve() { cin >> n >> m; { vector<int> v, w; v.resize(n); for(int i = 0; i < n; i++) { cin >> v[i]; } w.resize(m); for(int i = 0; i < m; i++) { cin >> w[i]; } sort(v.begin(), v.end()); sort(w.begin(), w.end()); int a = 0; int b = 0; while(a < v.size() && b < w.size()) { if(v[a] == w[b]) { v.erase(v.begin() + a); w.erase(w.begin() + b); } else if(v[a] < w[b]) a++; else b++; } n = v.size(); m = w.size(); for(int i = 0; i < n; i++) { val[i] = v[i]; } for(int i = 0; i < m; i++) { bases[i] = w[i]; } } sort(val, val+n); reverse(val, val+n); for(int mask = 1; mask < (1<<m); mask++) { int v = 0; int t = mask; while(v <= 1000 && t) { v += bases[__builtin_ctz(t)]; t &= t-1; } if(v <= 1000) masks[v].push_back(mask); } unordered_set<int> ret; ret.insert(0); for(int i = 0; i < n; i++) { unordered_set<int> nret; for(int out2: ret) { for(int out: masks[val[i]]) { if(out&out2) continue; if(__builtin_popcount(out | out2) + 2*(n-i-1) > m) continue; nret.insert(out | out2); } } ret = nret; } if(ret.empty()) cout << "NO\n"; else cout << "YES\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); solve(); }

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

bank.cpp: In function 'void solve()':
bank.cpp:29:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(a < v.size() && b < w.size()) {
           ~~^~~~~~~~~~
bank.cpp:29:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(a < v.size() && b < w.size()) {
                           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...