제출 #730315

#제출 시각아이디문제언어결과실행 시간메모리
730315Macker은행 (IZhO14_bank)C++17
100 / 100
112 ms8516 KiB
#include <iostream> #include <vector> #include <list> #include <algorithm> #include <math.h> #include <tuple> #include <queue> #include <stack> #include <unordered_map> #include <unordered_set> #include <set> #include <map> #include <climits> #include <fstream> #include <cassert> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() int main() { int n, m; cin >> n >> m; vector<int> p(n); for (auto& i : p) cin >> i; vector<int> b(m); for (auto& i : b) cin >> i; vector<pair<int, int>> dp((1 << m), {-1, -1}); dp[0] = { 0, p[0] }; for (int i = 1; i < (1 << m); i++) { for (int j = 0; j < m; j++) { if (!(i & (1 << j)))continue; int li = i ^ (1 << j); int k = dp[li].first, rem = dp[li].second; if (k == -1)continue; if (rem > b[j]) { rem -= b[j]; dp[i] = { k, rem }; } else if (rem == b[j]) { k++; if (k == p.size()) { cout << "YES" << endl; return 0; } rem = p[k]; dp[i] = { k, rem }; } } } cout << "NO" << endl; }

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

bank.cpp: In function 'int main()':
bank.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                 if (k == p.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...