#P1946. Olympic Medal Ranking Optimization
Olympic Medal Ranking Optimization
Olympic Medal Ranking Optimization
During the Olympic Games, teams are ranked according to a score computed from the number of medals they win. You are given the medal counts for n teams. Your team is team 1. Each team’s medal counts are given as three integers representing the number of gold, silver, and bronze medals respectively.
You are allowed to choose scoring parameters \(P_g, P_s, P_b\) for gold, silver, and bronze medals respectively. These parameters must satisfy the constraints \[ 1000 \ge P_g \ge P_s \ge P_b \ge 1 \] and a team’s total score is computed as \[ \text{score} = P_g \times (\text{gold}) + P_s \times (\text{silver}) + P_b \times (\text{bronze}). \]
Teams are then sorted in descending order by their scores. In order to boost your team’s ranking as high as possible, you need to choose a triple \((P_g, P_s, P_b)\) so that the score of team 1 is strictly greater than the score of every other team that it can possibly beat. Note that because of the constraint \(P_g \ge P_s \ge P_b\), the medal counts have a lexicographical priority: effectively, a team with a higher number of gold medals cannot be overtaken by another team that has fewer gold medals, regardless of the silver and bronze counts. Thus, team 1 can only hope to outrank a rival team if, in the lexicographical order (gold, then silver, then bronze), team 1 is larger than that team. If there exists any team whose medal counts are greater than or equal to team 1’s (in this lexicographical sense), then no valid choice of \(P_g, P_s, P_b\) can have team 1 scoring strictly higher than that team.
Your task is to determine the best (i.e. minimal) ranking that team 1 can achieve by a proper choice of \(P_g, P_s, P_b\), and to output one corresponding valid triple.
Note: If team 1 is already lexicographically inferior to some other teams then it is impossible to overtake those teams. In that case, the best ranking is \(1 + k\) where \(k\) is the number of teams that are not beatable by any scoring choice.
inputFormat
The first line contains a single integer \(n\) (\(2 \le n \le 100\)), representing the number of teams.
The following \(n\) lines each contain three nonnegative integers: the number of gold, silver, and bronze medals for each team. The first of these \(n\) lines corresponds to your team (team 1).
outputFormat
On the first line, output the best ranking that team 1 can achieve when an appropriate scoring triple is chosen.
On the second line, output three integers \(P_g\), \(P_s\), and \(P_b\) (separated by space) representing a valid scoring triple which yields that ranking.
sample
3
1 1 1
2 0 0
0 2 0
2
1 1 1
</p>