eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Таблица первенства

Таблица первенства

Once upon a time, in the archives of Byteland, an ancient table was found. The best scientists of Byteland identied this table as a scoreboard of the very first Byteland football championship. The table itself was in perfect condition  only a few numbers were missing. You need to help Byteland scientists to reconstruct the missing numbers based on the content of the table, or determine that unambiguous reconstruction is impossible. \InputFile The first line of the input le holds a single positive integer number \textbf{2} ≤ \textbf{N} ≤ \textbf{3·10^5}  the number of teams that participated in the very rst Byteland football championship. Each of the next \textbf{N} lines consists of the scoreboard itself. The championship was conducted in one round, which means that each team played with each other only once. Each line of the scoreboard shows the performance of one team in the following format: \textbf{1} ≤ \textbf{i} ≤ \textbf{N}  place of the team in the overall championship results, \textbf{N_i} - string of at most \textbf{300} Latin characters representing the name of the team, \textbf{N-1} - the same integer representing the number of games played by each team, \textbf{0} ≤ \textbf{W_i} ≤ \textbf{N-1}  number of matches won, \textbf{0} ≤ \textbf{D_i} ≤ \textbf{N-1} - number of draws, \textbf{0} ≤ \textbf{L_i} ≤ \textbf{N-1} - number of games lost, \textbf{0} ≤ \textbf{S_i} ≤ \textbf{3(N-1)} - number of score points earned by the team (each victory, draw and loss gives a team \textbf{3}, \textbf{1} and \textbf{0} points respectively). Elements in the line are separated by a single space. The table is sorted by the number of score points in descending order (and therefore in the ascending order of places). Some of the Wi;Di;Li; Si can be replaced by \textbf{-1} that means that the number is missing. It is guaranteed that the provided table can be constructed from a correct table by replacement of at most three numbers by \textbf{-1}. Help Bytelanders to reconstruct the scoreboard! \OutputFile Output the name of the team in the \textbf{i+1} line, where \textbf{i} is the minimum of reconstructed numbers or \textbf{-1} if i is greater than N unambiguous reconstruction is impossible.
Лимит времени 5 секунд
Лимит использования памяти 64 MiB
Входные данные #1
4
1 Bayern 3 2 1 0 7
2 Borussia 3 2 1 -1 7
3 Barcelona 3 1 0 2 3
4 Real 3 0 0 3 0
Выходные данные #1
Bayern
Источник Yandex.Algorithm, Test Round, 27/06/2013