QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB

#23985. Sports Contest

통계

問題文

32 チームが参加するスポーツ大会が行われる.それぞれのチームには 1 から 32 まで番号が付けられている.

チーム i (1 ≦ i ≦ 32) の強さは Ai で,すべてのチームの強さは互いに異なる.2 チームが試合をすると,強さが大きいチームが必ず勝つ.

大会は全 5 ラウンドのトーナメント戦で行われる.

第 1 ラウンドの開始時,チームは左からチーム 1, 2, …, 32 の順に一列に並んでいる.

各ラウンドでは,左から順に隣り合う 2 チームずつ組になり,それぞれ試合を行う. そのラウンドにおけるすべての試合が終了すると,それぞれの試合の勝者だけが次のラウンドに進む.勝者たちは,このラウンドで試合が行われた順番に左から一列に並び,次のラウンドに進む.

この操作をチームが 1 つになるまで繰り返す.第 5 ラウンドでは 2 チームが残り,試合を行う.この試合を決勝戦と呼び,決勝戦に勝ったチームが優勝,負けたチームが準優勝となる.

決勝戦である第 5 ラウンドの試合で敗れ,準優勝となるチームの番号を求めよ.

制約

  • 1 ≦ Ai≦ 1 000 (1 ≦ i ≦ 32).
  • Ai≠ Aj (1 ≦ i < j ≦ 32).
  • 入力される値はすべて整数である.

入力

入力は以下の形式で与えられる.
A1 A2 … A32

出力

準優勝するチームの番号を出力せよ.

答え以外は何も出力しないこと.(入力を促す文章なども出力しないこと.)

解答形式については,練習問題やその解答例 を参考にしても良い.


入力例 1

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

出力例 1

16

第 5 ラウンドの試合ではチーム 16 とチーム 32 が試合を行う.チーム 16 の強さは A16= 16 で,チーム 32 の強さは A32= 32 であるため,チーム 32 が勝利し,チーム 16 が準優勝となる.よって,16 を出力する.


入力例 2

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

出力例 2

25

第 5 ラウンドの試合ではチーム 11 とチーム 25 が試合を行う.チーム 11 の強さは A11= 32 で,チーム 25 の強さは A25= 31 であるため,チーム 11 が勝利し,チーム 25 が準優勝となる.よって,25 を出力する.


入力例 3

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

出力例 3

5

第 5 ラウンドの試合ではチーム 5 とチーム 22 が試合を行う.チーム 5 の強さは A5= 44 で,チーム 22 の強さは A22= 49 であるため,チーム 22 が勝利し,チーム 5 が準優勝となる.よって,5 を出力する.


入力例 4

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

出力例 4

5

第 5 ラウンドの試合ではチーム 5 とチーム 22 が試合を行う.チーム 5 の強さは A5= 912 で,チーム 22 の強さは A22= 975 であるため,チーム 22 が勝利し,チーム 5 が準優勝となる.よって,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.