Under construction

Still being built. Things may change

Programming-trampoline-athlon!

Interview

Time limit1sMemory limit1024 MB

Summary
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 33 members. The team has 11 hour, 11 computer, and 11 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 66 programming problems and 66 trampoline elements (exercises). The team decides how to divide the trampoline elements among its members, so that each team member performs exactly 22 of the given elements on the trampoline. The team members solve the programming tasks together, but no member may spend more than 2525 minutes on the computer in total. The score has two parts, which are added together:

  • The programming score ranges from 00 to 6060. The team receives 1010 points for each correctly solved problem.
  • The trampoline score ranges from 00 to 4040. Each of the 66 trampoline elements receives a score from the judges between 00 and 1010. The final trampoline score is the sum of the 44 remaining scores after dropping the highest and lowest of the 66 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 1 0001\,000 teams receive a medal. Write a program that determines the medallists, given the performance of each team.

Input

The first line contains the number NN of competing teams. Then NN lines follow. Each line describes one team and contains the space-separated values CC, PP, E1E_1, E2E_2, E3E_3, E4E_4, E5E_5, E6E_6. CC is a five-letter code that identifies the team, PP is an integer giving the number of problems the team solved, and EiE_i is an integer giving the execution score of trampoline element ii.

Output

The output contains MM lines, where MM is the number of medallist teams. Each line contains two space-separated values CC and SS, where CC is the team code and SS 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

  • 3≤N≤100 0003 \le N \le 100\,000
  • 3≤M≤1 0003 \le M \le 1\,000
  • CC consists of five uppercase English letters.
  • 0≤P≤60 \le P \le 6
  • 0≤Ei≤100 \le E_i \le 10 for all 1≤i≤61 \le i \le 6
  • Different teams always have different team codes.

Examples2

  1. Example 1

    Input
    5
    EMAIL 3 5 6 7 8 9 10
    CRASH 2 7 1 8 2 8 1
    MOUSE 4 0 9 3 9 1 7
    SWERC 6 3 1 4 1 5 9
    PAINT 6 0 0 0 0 0 10
    
    Expected output
    SWERC 73
    EMAIL 60
    MOUSE 60
    PAINT 60
    
  2. Example 2

    Input
    4
    CRAZY 4 0 2 4 6 8 10
    JAZZY 2 9 9 9 9 9 9
    JUICY 3 2 9 10 9 10 1
    FUZZY 5 0 1 1 2 3 5
    
    Expected output
    CRAZY 60
    JUICY 60
    FUZZY 57