제출 #1056432

#제출 시각아이디문제언어결과실행 시간메모리
1056432vjudge1은행 (IZhO14_bank)C++17
100 / 100
95 ms20772 KiB
#include<bits/stdc++.h> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 1048576 + 7; ii dp[mxN]; int n, m, a[mxN], b[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; dp[0].fi = 1; for (int i = 0; i < (1 << m); i++) { if (dp[i].se == a[dp[i].fi]) { dp[i].fi++; dp[i].se = 0; } if (dp[i].fi > n) { cout << "YES"; return 0; } for (int j = 0; j < m; j++) { int nw = i | (1 << j); if (nw == i) continue; dp[nw] = max(ii(dp[i].fi, dp[i].se + b[j]), dp[nw]); } } cout << "NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...