#C14712. Inventory Management
Inventory Management
Inventory Management
You are given the current day and a list of inventory items. Each item has a name, a quantity, and a shelf life expressed as the number of days until it expires. An item is considered to be expiring soon if its shelf life is at most 2 days. Your task is to output all items that expire within the next two days, preserving their input order.
Note: The expiration condition can be expressed by the inequality \[ \text{shelf_life} \le 2 \] where \(\text{shelf_life}\) is the number of days until the item expires.
inputFormat
The first line of input contains two space-separated integers: current_day
and n
, where n
is the number of items.
The next n
lines each describe an item with three entries: a string name
(without spaces), an integer quantity
, and an integer shelf_life
.
For example:
5 4 Milk 10 3 Bread 20 1 Eggs 30 7 Cheese 5 2
outputFormat
For every item that expires within the next two days (i.e. with shelf_life ≤ 2
), print a line containing the item's name, quantity, and shelf life, separated by spaces, and in the same order as they appear in the input.
If no items satisfy the condition, output nothing.
## sample5 4
Milk 10 3
Bread 20 1
Eggs 30 7
Cheese 5 2
Bread 20 1
Cheese 5 2
</p>