#C8804. Prioritize Customer Queries

    ID: 52827 Type: Default 1000ms 256MiB

Prioritize Customer Queries

Prioritize Customer Queries

You are given a list of customer queries. Each query is represented by a unique query id, a priority level, and a timestamp. The priority level is one of high, medium, or low. The goal is to process queries in the following order:

  • Queries with higher priority are handled before lower ones. Here, the priority order is defined as: \(high < medium < low\) (with high considered as the smallest number when mapped to \(1,2,3\)).
  • If two queries have the same priority level, the query with the smaller (earlier) timestamp is processed first.

You are required to print the list of query ids in the order they should be processed.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  1. The first line contains a single integer \(n\) representing the number of queries.
  2. The next \(n\) lines each contain three values separated by spaces: query_id (an integer), priority (a string which can be "high", "medium", or "low"), and timestamp (an integer).

outputFormat

Output a single line to standard output (stdout) which contains the query ids in the order they should be processed, separated by a single space.

## sample
5
1 low 1623476524
2 high 1623474580
3 medium 1623476590
4 high 1623476391
5 medium 1623476100
2 4 5 3 1