시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB22181482.353%

문제

You work for the IT department of a major league baseball team. Baseball has an almost infinite number of stats—what a great job for a computer program!

You will write a program to determine who will bat 4th in the batting order. This is called the “clean-up” position and some managers use the person with the best batting average.

You will be given the roster (with their hits and at bats). The clean-up batter will be fourth and have the highest batting average.

You will also be given a series of hits and at bats which may change the best current batting average. Here are three possibilities:

  1. The clean-up batter still has the greatest average (no change!)
  2. One of the first 3 batters now has the greatest—switch positions with the clean-up hitter.
  3. One of the last 5 batters now has the greatest—insert the newest batter at the fourth position and the 4th becomes the 5th, the 5th becomes the 6th… until the old batting position is reached.

입력

The first 9 lines consist of the current roster (last name only) and their past hits and at bats. The next 9 lines consist of the hits and at bats for the next series of games (in the same order as the roster).

출력

Show the new roster with the highest batting average in the clean-up position.

예제 입력 1

Uecker 15 150
Ruth 50 150
Canseco 45 150
Beltre 55 150
Cruz 51 150
Kinsler 44 150
Andrus 40 150
Moreland 35 150
Darvish 10 150
0 10
5 10
0 10
0 10
9 10
5 10
5 10
5 10
1 10

예제 출력 1

Uecker
Ruth
Canseco
Cruz
Beltre
Kinsler
Andrus
Moreland
Darvish