#P1946. Olympic

Olympic

Description

The Olympic Games are in full swing, and many teams on the medal table need to be ranked. You need to choose three integers Pg,PsP_g, P_s and PbP_b, representing the score awarded for each gold, silver, and bronze medal, respectively, and they must satisfy 1000PgPsPb11000 \ge P_g \ge P_s \ge P_b \ge 1. Teams will be sorted by their scores in descending order. Now, to make your own team rank as high as possible, you will choose Pg,Ps,PbP_g, P_s, P_b.

Input Format

The first line contains an integer nn (1n151 \le n \le 15), indicating that there are nn teams to be ranked.

Each of the following nn lines contains three integers G,S,BG, S, B (0G,S,B1050 \le G, S, B \le 10^5), representing the numbers of gold, silver, and bronze medals obtained by each team.

  • The first team is your team.
  • If the scores are equal, your team ranks first.

Output Format

Output three numbers Pg,Ps,PbP_g, P_s, P_b in one line, separated by spaces.

If there are multiple solutions, output the one with the smallest PgP_g. If there are still multiple solutions, output the one with the smallest PsP_s. If there are still multiple solutions, output the one with the smallest PbP_b.

3
1 1 1
0 1 2
2 1 0
1 1 1

Hint

Constraints

  • For 10%10\% of the testdata, it is guaranteed that the optimal solution has Pg10P_g \le 10.
  • For 30%30\% of the testdata, it is guaranteed that the optimal solution has Pg100P_g \le 100.

Translated by ChatGPT 5