제출 #727433

#제출 시각아이디문제언어결과실행 시간메모리
727433AndrijaM은행 (IZhO14_bank)C++14
100 / 100
239 ms113644 KiB
#include <iostream> #include <fstream> #include <vector> #include <map> #include <cstring> #include <queue> #include <algorithm> //#include <bits/stdc++.h> using namespace std; const int maxn = 1005 * 1005; vector<int> masks[maxn]; int salary[maxn]; int notes[maxn]; int dp[20][1 << 20]; int rec(int at, int bitmask) { if(at == -1) { return 1; } if(dp[at][bitmask] != -1) { return dp[at][bitmask]; } int result = 0; for(int i = 0; i < masks[salary[at]].size(); i++) { int tmp_mask = masks[salary[at]][i]; if((tmp_mask & bitmask) == tmp_mask) { result |= rec(at - 1, bitmask ^ tmp_mask); } } return dp[at][bitmask] = result; } int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; for(int i = 0; i < n; i++) { cin >> salary[i]; } for(int i = 0; i < m; i++) { cin >> notes[i]; } for(int bitmask = 0; bitmask < (1 << m); bitmask++) { int sum = 0; for(int i = 0; i < m; i++) { if(bitmask & (1 << i)) { sum += notes[i]; } } masks[sum].push_back(bitmask); } memset(dp, -1, sizeof dp); cout << (rec(n - 1, (1 << m) - 1) == 1 ? "YES" : "NO") << endl; return 0; }

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

bank.cpp: In function 'int rec(int, int)':
bank.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i = 0; i < masks[salary[at]].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...