Stock-order processing
Stock-order processing
AS 9618 · Algorithm writing
Read the question below and attempt it before opening support. Use the specified input/output contract. Check runs several independent cases; one sample output is not enough.
Stock is 9. Requests are 4, 0, 6, 5. A positive request is accepted only if it fits. Give Stock after each request.
With Stock = 5, valid request quantities are 1 to 5. Give four boundary test quantities in ascending order, including just-outside values.
Read initial Stock (non-negative), N (1 to 6), then N requested quantities. A request must be positive and no greater than current Stock. For each request output accepted and subtract it, or rejected and leave Stock unchanged. Finally output Stock.
Нажмите Запустить, чтобы увидеть результат здесь.