AT_abc476_c.Third Largest Number
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer N not less than 3 and a length-N sequence of positive integers A=(A1,A2,…,AN).
For each k=3,4,…,N, solve the following problem:
- When A1,A2,…,Ak are sorted in descending order, find the third value from the front.
给定一个不小于 3 的整数 N,以及一个长度为 N 的正整数序列 A=(A1,A2,…,AN)。
对每个 k=3,4,…,N,求解以下问题:
- 将 A1,A2,…,Ak 按降序排序后,找出从前往后数的第三个值。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
输出格式
Output N−2 lines.
The i-th line (1≤i≤N−2) should contain the answer for k=i+2.
输出 N−2 行。
第 i 行(1≤i≤N−2)应包含 k=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=3: sorting A1,A2,A3 in descending order gives 2,1,1. The third value from the front is 1, so output 1 on the first line.
- For k=4: sorting A1,A2,A3,A4 in descending order gives 2,2,1,1. The third value from the front is 1, so output 1 on the second line.
- For k=5: sorting A1,A2,A3,A4,A5 in descending order gives 3,2,2,1,1. The third value from the front is 2, so output 2 on the third line.
Constraints
- 3≤N≤5×105
- 1≤Ai≤109
- All input values are integers.
样例 1 解释:
- 当 k=3 时:将 A1,A2,A3 按降序排序得到 2,1,1,从前数第 3 个值为 1,因此在第一行输出 1。
- 当 k=4 时:将 A1,A2,A3,A4 按降序排序得到 2,2,1,1,从前数第 3 个值为 1,因此在第二行输出 1。
- 当 k=5 时:将 A1,A2,A3,A4,A5 按降序排序得到 3,2,2,1,1,从前数第 3 个值为 2,因此在第三行输出 2。
限制条件
- 3≤N≤5×105
- 1≤Ai≤109
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?