Programming-trampoline-athlon!
InterviewTime limit1sMemory limit1024 MB
Given each team's solved problem count and six trampoline scores, compute totals and list the teams with at most two teams scoring strictly higher.
- Level
Easy3 of 10
- Topics
- Sorting, Implementation
- Solved
- No attempts yet
Problem
Programming competitions are fun and exciting. Programming should be an Olympic sport! At least, this is what we believe. However, when we suggested this to some of our friends, they did not seem to share our excitement. So, we decided to suggest a combined sport that will be more interesting to watch. Programming-trampoline-athlon! (we are still working on the name.)
The idea is as follows. This is a team sport, where each team consists of members. The team has hour, computer, and trampoline at its disposal. At all times, at most one team member must use the computer, and at least one team member must be jumping on the trampoline. At the start of the competition, the team receives programming problems and trampoline elements (exercises). The team decides how to divide the trampoline elements among its members, so that each team member performs exactly of the given elements on the trampoline. The team members solve the programming tasks together, but no member may spend more than minutes on the computer in total. The score has two parts, which are added together:
- The programming score ranges from to . The team receives points for each correctly solved problem.
- The trampoline score ranges from to . Each of the trampoline elements receives a score from the judges between and . The final trampoline score is the sum of the remaining scores after dropping the highest and lowest of the scores.
Before we pitch this new sport to the International Olympic Committee, we want everything ready to show them how serious we are. Each team receives a medal when no more than two other teams have a strictly higher score. However, because of a recent shortage of medals, the jury was instructed to make sure that no more than teams receive a medal. Write a program that determines the medallists, given the performance of each team.
Input
The first line contains the number of competing teams. Then lines follow. Each line describes one team and contains the space-separated values , , , , , , , . is a five-letter code that identifies the team, is an integer giving the number of problems the team solved, and is an integer giving the execution score of trampoline element .
Output
The output contains lines, where is the number of medallist teams. Each line contains two space-separated values and , where is the team code and is the total score of the team. Print the medallist teams in decreasing order of total score. Teams with equal scores appear in input order.
Constraints
- consists of five uppercase English letters.
- for all
- Different teams always have different team codes.