#include #include #include #include template using MaxHeap = std::priority_queue; using lint = long long; const std::vector money{10000, 5000, 1000}; void solve() { int n; std::cin >> n; std::vector xs(3); for (auto& x : xs) std::cin >> x; std::reverse(xs.begin(), xs.end()); MaxHeap heap; while (n--) { lint a; std::cin >> a; heap.push(++a); } for (int i = 0; i < 3; ++i) { while (xs[i] > 0 && !heap.empty()) { auto a = heap.top(); heap.pop(); auto need = a / money[i]; if (need == 0) { --xs[i]; a = 0; } else { auto pay = std::min(xs[i], need); xs[i] -= pay; a -= money[i] * pay; } if (a > 0) heap.push(a); } } std::cout << (heap.empty() ? "Yes" : "No") << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }