#K70992. Toy Restocking Priority Calculator

    ID: 33431 Type: Default 1000ms 256MiB

Toy Restocking Priority Calculator

Toy Restocking Priority Calculator

You are given a list of toys with their details and you are to determine the order in which they should be restocked. Each toy is described by an ID, a name, the current stock level, the total borrow count, and the number of days until its return.

The restocking priority for a toy is calculated by the formula \[ \text{priority} = \text{borrow_count} \times (365 - \text{days_until_return}) - \text{stock} \] In other words, toys that have been borrowed more frequently and are expected to return sooner should be restocked first.

If two toys have the same priority, the toy that appears earlier in the input order should come first in the output.

Your task is to read the toy data, compute the priorities, sort the toys in descending order according to their priority (with ties resolved by input order), and output the sorted toy IDs separated by a single space.

inputFormat

The first line contains an integer N, the number of toys.

Each of the following N lines contains five space-separated values: id (a string), name (a string without spaces), stock (an integer), borrow_count (an integer), and days_until_return (an integer).

outputFormat

Output a single line with the toy IDs sorted by their restocking priority. The IDs should be separated by a single space. If there are no toys, output an empty line.

## sample
3
T001 TeddyBear 5 200 30
T002 LegoSet 2 100 15
T003 Puzzle 0 300 60
T003 T001 T002

</p>