/*    ∫ ∫ ∫    ノヽ   (_  )  (_    ) (______ )  ヽ(´・ω・)ノ     |  /    UU */ #pragma region macro #include typedef long long int64; using namespace std; using P = pair; typedef vector vi; const int MOD = (int)1e9 + 7; const int64 INF = 1LL << 62; const int inf = 1<<30; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b ostream& operator<<(ostream& os, const vector &V){ int N = V.size(); REP(i,N){ os << V[i]; if (i!=N-1) os << " "; } os << "\n"; return os; } template ostream& operator<<(ostream& os, pair const&P){ os << "("; os << P.first; os << " , "; os << P.second; os << ")"; return os; } template ostream& operator<<(ostream& os, set &S){ auto it=S.begin(); while(it!=S.end()){ os << *it; os << " "; it++; } os << "\n"; return os; } template ostream& operator<<(ostream& os, deque &q){ for(auto it=q.begin();it> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)}; #pragma endregion //fixed<> N >> X >> Y >> Z; vector A(N); REP(i,N) cin >> A[i]; sort(ALL(A)); int pay; for(auto& a:A){ if(a>=10000 && Z){ pay = min(a/10000,Z); Z-=pay; a-=10000*pay; } if(a>=5000 && Y){ pay = min(a/5000,Y); Y-=pay; a-=5000*pay; } } sort(ALL(A),greater()); /* 5000円札が不足していたら5000以上もあり得る 1万円札が残っているなら、大きい順にそれで払えばいい 5000円が残っているなら、大きい順にそれで払えばいい 残りは1000円で払うしかない */ for(auto& a:A){ if(a>=0){ if(Z>0){ Z--; continue; } if(Y>0){ Y--; continue; } if(a>=1000*X){ cout << "No" << bn; return 0; } X-=(a+999)/1000; } } cout << "Yes" << bn; }