제출 #930411

#제출 시각아이디문제언어결과실행 시간메모리
930411uped은행 (IZhO14_bank)C++14
100 / 100
95 ms8652 KiB
#include <bits/stdc++.h> #define DEBUG(x) cout << #x << ": " << x << '\n'; using namespace std; using ll = long long; int main() { int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> b(m); for (int i = 0; i < m; ++i) { cin >> b[i]; } // dp of subset X -> num of people in prefix, leftover sum. // left-over must equal be for num of people and set // so we must maximize prefix vector<pair<int, int>> dp(1 << m, {-1, -1}); dp[0] = {0, 0}; bool ok = false; for (int i = 1; i < (1 << m); ++i) { for (int j = 0; j < m; ++j) { if (!(i & (1 << j))) continue; // j not in i auto& [cnt, leftover] = dp[i ^ (1 << j)]; if (cnt == -1) continue; // impossible state int target = a[cnt]; // current salary we try to fill // only one can be always satisfied! if (leftover + b[j] < target) { dp[i] = {cnt, leftover + b[j]}; } else if (leftover + b[j] == target) { dp[i] = {cnt + 1, 0}; } } if (dp[i].first == n) { ok = true; break; } } cout << (ok ? "YES" : "NO"); }

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

bank.cpp: In function 'int main()':
bank.cpp:28:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |             auto& [cnt, leftover] = dp[i ^ (1 << j)];
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...