QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB

#23985. Sports Contest

統計

Problem Statement

A sports tournament with $32$ participating teams will be held. Each team is numbered from $1$ to $32$.

The strength of team $i$ ($1 \le i \le 32$) is $A_i$, and the strengths of all teams are pairwise distinct. When $2$ teams play a match, the team with the greater strength always wins.

The tournament is played as a knockout tournament over a total of $5$ rounds.

At the start of Round $1$, the teams are lined up in a single row from left to right in the order of teams $1, 2, \dots, 32$.

In each round, every $2$ adjacent teams from left to right are paired up, and each pair plays a match. Once all matches in that round are finished, only the winner of each match advances to the next round. The winners line up in a single row from left to right in the order in which their matches were played in this round, and advance to the next round.

This operation is repeated until only $1$ team remains. In Round $5$, $2$ teams remain and play a match. This match is called the final; the team that wins the final becomes the champion, and the team that loses becomes the runner-up.

Find the number of the team that loses in the final (the match in Round $5$) and becomes the runner-up.

Constraints

  • $1 \le A_i \le 1\,000$ ($1 \le i \le 32$).
  • $A_i \ne A_j$ ($1 \le i < j \le 32$).
  • All input values are integers.

Input

The input is given in the following format:

A_1 A_2 … A_32

Output

Print the number of the runner-up team.

Do not print anything other than the answer. (For example, do not print any text prompting for input.)

For the answer format, you may refer to the practice problems and their sample solutions.

Sample 1

Input

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Output

16

In the Round $5$ match, team $16$ and team $32$ play against each other. Since the strength of team $16$ is $A_{16} = 16$ and the strength of team $32$ is $A_{32} = 32$, team $32$ wins and team $16$ becomes the runner-up. Therefore, print $16$.

Sample 2

Input

15 17 29 6 7 19 16 26 20 13 32 5 21 4 27 2 22 12 14 28 24 8 30 10 31 1 11 18 25 3 23 9

Output

25

In the Round $5$ match, team $11$ and team $25$ play against each other. Since the strength of team $11$ is $A_{11} = 32$ and the strength of team $25$ is $A_{25} = 31$, team $11$ wins and team $25$ becomes the runner-up. Therefore, print $25$.

Sample 3

Input

19 2 5 12 44 40 24 16 3 26 23 21 41 28 9 39 43 22 15 14 7 49 17 46 34 4 32 30 45 27 33 36

Output

5

In the Round $5$ match, team $5$ and team $22$ play against each other. Since the strength of team $5$ is $A_5 = 44$ and the strength of team $22$ is $A_{22} = 49$, team $22$ wins and team $5$ becomes the runner-up. Therefore, print $5$.

Sample 4

Input

538 714 395 303 912 315 903 629 588 760 590 344 794 577 541 193 404 325 544 536 435 975 340 511 806 769 44 95 741 519 332 973

Output

5

In the Round $5$ match, team $5$ and team $22$ play against each other. Since the strength of team $5$ is $A_5 = 912$ and the strength of team $22$ is $A_{22} = 975$, team $22$ wins and team $5$ becomes the runner-up. Therefore, print $5$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.