#K85462. Taxi Fare Analysis
Taxi Fare Analysis
Taxi Fare Analysis
You are given data about taxi rides. Each ride is specified by a company ID, the distance traveled, and the fare charged. Your task is to group the rides by company and sort them. For each company, the rides must be ordered in increasing order of distance. If two or more rides from the same company have the same distance, they should be sorted by fare in descending order. Finally, the results should be combined in increasing order of the company ID.
The sorting criteria can be summarized as:
[ \text{Sort by } (\text{company_id}, \text{distance (ascending)}, -\text{fare} ) ]
Implement the solution so that it reads input from standard input (stdin) and prints the output on standard output (stdout).
inputFormat
The first line contains an integer M representing the number of taxi rides. Each of the next M lines contains three values: company_id (an integer), distance (an integer), and fare (a float). Input is provided via standard input (stdin).
outputFormat
Output the sorted taxi rides, one ride per line. Each line should have the company_id, distance, and fare (formatted to two decimal places), separated by a space. The output should be printed to standard output (stdout).## sample
6
1 10 15.75
2 15 19.50
1 5 12.00
2 15 20.00
1 5 15.00
2 20 25.00
1 5 15.00
1 5 12.00
1 10 15.75
2 15 20.00
2 15 19.50
2 20 25.00
</p>