제출 #875800

#제출 시각아이디문제언어결과실행 시간메모리
875800Beerus13은행 (IZhO14_bank)C++14
100 / 100
102 ms8796 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define bit(mask, i) ((mask >> i) & 1) const int ar = 20; int n, m, a[ar], b[ar]; pair<int, int> dp[1 << 20]; int main() { ios::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]; for(int i = 1; i < (1 << m); ++i) dp[i].first = -1; for(int mask = 0; mask < (1 << m); ++mask) { for(int i = 0; i < m; ++i) if(bit(mask, i)) { auto [sz, val] = dp[mask ^ (1 << i)]; if(sz == -1) continue; if(val + b[i] == a[sz]) dp[mask] = {sz + 1, 0}; else if(val + b[i] < a[sz]) dp[mask] = {sz, b[i] + val}; } if(dp[mask].first == n) return cout << "YES\n", 0; } cout << "NO\n"; }

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

bank.cpp: In function 'int main()':
bank.cpp:19:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |             auto [sz, val] = dp[mask ^ (1 << 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...