#include using namespace std; #define rep(i,n) for(int i=0; i P; int main(){ ll N,M; //string S; cin >> N; vector A(N); ll X,Y,Z; cin >> X>>Y>>Z; rep(i,N){ cin >> A[i]; } sort(A.begin(), A.end(), greater()); rep(i,N){ ll rz = min(Z, A[i] / 10000); ll tmp = A[i] - rz*10000; ll ry = min(Y, tmp / 5000); tmp = tmp - ry*5000; ll rx = min(X, tmp / 1000); tmp = tmp - rx*1000; X -= rx; Y -= ry; Z -= rz; //cout << X <<" "<= 0){ if(X > 0){ X--; }else if(Y > 0){ Y--; }else if(Z > 0){ Z--; }else{ cout << "No" <0){ X--; continue; }else if(A[i] < 5000 && Y > 0){ Y--; continue; }else if(A[i] < 10000 && Z > 0){ Z--; continue; } while(A[i] >= 10000 && Z>0){ A[i] -= 10000; Z--; } while(A[i] >= 5000 && Y>0){ A[i] -= 5000; Y--; } while(A[i] >= 1000 && X>0){ A[i] -= 1000; X--; } if(A[i] >= 1000){ cout << "No" <= 0){ if(X > 0){ X--; }else if(Y > 0){ Y--; }else if(Z > 0){ Z--; }else{ cout << "No" <