제출 #1057400

#제출 시각아이디문제언어결과실행 시간메모리
1057400ssitaram은행 (IZhO14_bank)C++17
100 / 100
91 ms8672 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); int n, m; cin >> n >> m; vector<int> goals(n); for (int& i : goals) cin >> i; vector<int> b(m); for (int& i : b) cin >> i; vector<pair<int, int>> dp(1 << m); for (int mask = 1; mask < (1 << m); ++mask) { for (int i = 0; i < m; ++i) { if (mask & (1 << i)) { pair<int, int> st = dp[mask ^ (1 << i)]; st.second += b[i]; if (st.second > goals[st.first]) { continue; } if (st.second == goals[st.first]) { ++st.first; st.second = 0; if (st.first == n) { cout << "YES\n"; return 0; } } dp[mask] = max(dp[mask], st); } } } cout << "NO\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...