#C8318. Runner Ranking

    ID: 52287 Type: Default 1000ms 256MiB

Runner Ranking

Runner Ranking

You are given a list of runners with their segment completion times. Each runner is represented by an ID and a list of segment times. The total time for a runner is computed as the sum of all his segment times.

Your task is to rank the runners in ascending order of their total time. In case two runners have the same total time, rank them in lexicographical order by their IDs.

The formula for the total time is given by: \( total\_time = \sum_{i=1}^{K} time_i \), where \( K \) is the number of segments for the runner.

inputFormat

The input is read from standard input and has the following format:

  1. An integer \( N \) representing the number of runners.
  2. Then \( N \) lines follow, each representing a runner's data in the format:
id K time1 time2 ... timeK

where id is a string identifier, K is the number of segments, and time1, time2, ..., timeK are the segment completion times (integers).

outputFormat

Output the ranked list of runners to standard output. Each line should contain the runner's id and their total_time (i.e. the sum of all segment times) separated by a space.

The ordering should be in ascending order of total_time, and in the case of a tie, by the runner's id in lexicographical order.

## sample
3
runner1 3 300 200 400
runner2 3 250 300 350
runner3 3 300 200 100
runner3 600

runner1 900 runner2 900

</p>