#C834. Fast Food Ordering System
Fast Food Ordering System
Fast Food Ordering System
You are required to simulate a fast food ordering system. The system processes two types of commands:
ORDER id priority
: Add a new order with an identifierid
and an integerpriority
. Here, a lower number indicates a higher priority.PROCESS
: Process the order with the highest priority. If two orders have the same priority, the one that was received earlier is processed first. If there are no orders to process, outputNO ORDER
.
For example, given the sequence of commands:
ORDER A1 3 ORDER B2 1 ORDER C3 2 PROCESS PROCESS PROCESS
the expected outputs would be:
B2 C3 A1
Use a priority queue where the ordering is defined by the pair \( (priority, counter) \) with counter
representing the order in which the commands were received.
inputFormat
The input is provided via standard input (stdin) and contains multiple lines. Each line represents a command, which is either:
ORDER id priority
PROCESS
Process the input until the end of file (EOF).
outputFormat
For each PROCESS
command in the input, output the identifier of the order processed. If no order is available, output NO ORDER
. The outputs should be printed via standard output (stdout), each on a new line.
ORDER A1 3
ORDER B2 1
ORDER C3 2
PROCESS
PROCESS
PROCESS
B2
C3
A1
</p>