103291: [Atcoder]ABC329 B - Next
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:9
Solved:0
Description
Score : $200$ points
Problem Statement
You are given $N$ integers $A_1, A_2, \ldots, A_N$. Find the largest among those integers that are not the largest.
The constraints of this problem guarantee that the answer exists.
Constraints
- $2 \leq N \leq 100$
- $1 \leq A_i \leq 100$
- It is not the case that all $A_1, A_2, \ldots, A_N$ are equal.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $A_1$ $A_2$ $\ldots$ $A_N$
Output
Print the answer.
Sample Input 1
5 2 1 3 3 2
Sample Output 1
2
The largest integer among $2,1,3,3,2$ is $3$.
The integers that are not $3$ among $2,1,3,3,2$ are $2,1,2$, among which the largest is $2$.
Sample Input 2
4 4 3 2 1
Sample Output 2
3
Sample Input 3
8 22 22 18 16 22 18 18 22
Sample Output 3
18
Output
得分:$200$分
问题描述
给你$N$个整数$A_1, A_2, \ldots, A_N$。找出那些不是最大的整数中的最大值。
本问题的约束条件保证了答案一定存在。
约束条件
- $2 \leq N \leq 100$
- $1 \leq A_i \leq 100$
- 不满足$A_1, A_2, \ldots, A_N$都相等。
- 所有输入值都是整数。
输入
输入数据从标准输入以如下格式给出:
$N$ $A_1$ $A_2$ $\ldots$ $A_N$
输出
输出答案。
样例输入1
5 2 1 3 3 2
样例输出1
2
在$2,1,3,3,2$中最大的整数是$3$。
在$2,1,3,3,2$中不是$3$的整数是$2,1,2$,其中最大的是$2$。
样例输入2
4 4 3 2 1
样例输出2
3
样例输入3
8 22 22 18 16 22 18 18 22
样例输出3
18
HINT
输出n个数中的次大值?