제출 #1109962

#제출 시각아이디문제언어결과실행 시간메모리
1109962DON_F은행 (IZhO14_bank)C++14
0 / 100
2 ms460 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; #define all(x) x.begin(), x.end() #define L(i, b, e) for (int i = b; i < e; ++i) #define R(i, b, e) for (int i = b; i >= e; --i) #define pb emplace_back #define vi vector<int> #define sz(x) ((int) x.size()) int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vi a(n), b(m); L(i, 0, n)cin >> a[i]; L(i, 0, m)cin >> b[i]; vector<pair<int, int>> dp(1 << m, {-1, -1}); dp[0] = {0, 0}; L(i, 0, 1 << m){ L(j, 0, m){ if ((1 << j) & i)continue; if (dp[i].second < n && dp[i].first + j <= a[dp[i].second]){ dp[i + (1 << j)] = {(dp[i].first + j == a[dp[i].second] ? 0 : dp[i].first + j), (dp[i].first + j == a[dp[i].second] ? dp[i].second + 1 : dp[i].second)}; } } } int ans = 0; L(i, 0, 1 << m)if (dp[i].second == n)ans = 1; cout << (ans ? "YES\n" : "NO\n"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...