#K11181. Taco Order Processing
Taco Order Processing
Taco Order Processing
You are given a list of orders, where each order is represented by five attributes:
- order_time: The time the order was placed.
- cooking_time: The time required to prepare the order.
- priority: The priority of the order (higher values indicate higher priority).
- customer_name: The name of the customer.
- order_id: The unique identifier for the order.
Your task is to sort the orders according to the following criteria:
- Sort by priority in descending order.
- If priorities are equal, sort by order_time in ascending order.
- If order_times are equal, sort by cooking_time in ascending order.
- If cooking_times are equal, sort by customer_name in lexicographical order (i.e. ascending).
- If customer_names are equal, sort by order_id in ascending order.
After sorting, output each order in a single line in the following space-separated format:
order_time cooking_time priority customer_name order_id
Note: When comparing numbers, treat order_time, cooking_time, priority and order_id as integers.
The sorting criteria in terms of mathematical notation can be represented as follows:
\[ \text{sorted}(orders) = orders\; \text{sorted by}\; \left(-priority,\; order\_time,\; cooking\_time,\; customer\_name,\; order\_id\right) \]
inputFormat
The input is read from stdin and has the following format:
n order_time_1 cooking_time_1 priority_1 customer_name_1 order_id_1 order_time_2 cooking_time_2 priority_2 customer_name_2 order_id_2 ... order_time_n cooking_time_n priority_n customer_name_n order_id_n
Where n
is the number of orders. Each order is given in a new line with a space-separated list of values. The attributes order_time
, cooking_time
, priority
, and order_id
are integers, while customer_name
is a string without spaces.
outputFormat
Output the sorted orders to stdout. Each order should be printed on a new line in the following space-separated format:
order_time cooking_time priority customer_name order_id
No extra spaces or lines should be printed.
## sample0