AT_abc476_c.Third Largest Number

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer NN not less than 33 and a length-NN sequence of positive integers A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N).

For each k=3,4,…,Nk=3,4,\ldots,N, solve the following problem:

  • When A1,A2,…,AkA_1,A_2,\ldots,A_k are sorted in descending order, find the third value from the front.

给定一个不小于 33 的整数 NN,以及一个长度为 NN 的正整数序列 A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N)。

对每个 k=3,4,…,Nk=3,4,\ldots,N,求解以下问题:

  • 将 A1,A2,…,AkA_1,A_2,\ldots,A_k 按降序排序后,找出从前往后数的第三个值。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 …\ldots ANA_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\ldots ANA_N

输出格式

Output N−2N-2 lines.

The ii-th line (1≤i≤N−2)(1\le i\le N-2) should contain the answer for k=i+2k=i+2.

输出 N−2N-2 行。

第 ii 行(1≤i≤N−21\le i\le N-2)应包含 k=i+2k=i+2 时的答案。

输入输出样例

  • 输入#1

    5
    1 2 1 2 3

    输出#1

    1
    1
    2
  • 输入#2

    10
    1 1 1 3 2 5 4 3 6 5

    输出#2

    1
    1
    1
    2
    3
    3
    4
    5
  • 输入#3

    10
    11 9 1 3 17 19 10 19 17 3

    输出#3

    1
    3
    9
    11
    11
    17
    17
    17

说明/提示

Sample 1 Explanation:

  • For k=3k=3: sorting A1,A2,A3A_1,A_2,A_3 in descending order gives 2,1,12,1,1. The third value from the front is 11, so output 11 on the first line.
  • For k=4k=4: sorting A1,A2,A3,A4A_1,A_2,A_3,A_4 in descending order gives 2,2,1,12,2,1,1. The third value from the front is 11, so output 11 on the second line.
  • For k=5k=5: sorting A1,A2,A3,A4,A5A_1,A_2,A_3,A_4,A_5 in descending order gives 3,2,2,1,13,2,2,1,1. The third value from the front is 22, so output 22 on the third line.

Constraints

  • 3≤N≤5×1053\le N\le 5\times 10^5
  • 1≤Ai≤1091\le A_i\le 10^9
  • All input values are integers.

样例 1 解释:

  • 当 k=3k=3 时:将 A1,A2,A3A_1,A_2,A_3 按降序排序得到 2,1,12,1,1,从前数第 3 个值为 11,因此在第一行输出 11。
  • 当 k=4k=4 时:将 A1,A2,A3,A4A_1,A_2,A_3,A_4 按降序排序得到 2,2,1,12,2,1,1,从前数第 3 个值为 11,因此在第二行输出 11。
  • 当 k=5k=5 时:将 A1,A2,A3,A4,A5A_1,A_2,A_3,A_4,A_5 按降序排序得到 3,2,2,1,13,2,2,1,1,从前数第 3 个值为 22,因此在第三行输出 22。

限制条件

  • 3≤N≤5×1053\le N\le 5\times 10^5
  • 1≤Ai≤1091\le A_i\le 10^9
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页