AlgorithmOJ
Problem
Local Problems
All Problems
Problem Category
Status
Contest
Standard Contests
Replay Contests
Virtual Contests
Ranklist
More...
News
About
F.A.Q
Recent Contests
Coming Soon...
Login
Register
2026-07-23 15:48:43
寻找第二小的数
Time Limit:
1000ms
Memory Limit:
32768KB
64-bit integer IO format:
%lld
Java class name:
Main
Prev
Submit
Status
Statistics
Next
Font Size:
Description
求n个整数中第二小的数。
相同的整数看成一个数。比如,有5个数分别是1,1,3,4,5,那么第二小的数就是3。
Input
输入包含多组测试数据。输入的第一行是一个整数C,表示有C组测试数据;
每组测试数据的第一行是一个整数n,表示本组测试数据有n个整数(2<=n<=10),接着一行是n个整数(每个数均小于100)。
Output
为每组测试数据输出第二小的整数,如果不存在第二小的整数则输出“NO”,每组输出占一行。
Sample Input
3 2 1 2 5 1 1 3 4 5 3 1 1 1
Sample Output
2 3 NO
Author
Admin
Language:
C++ (GCC 5.4.0)
C++11 (GCC 5.4.0)
C++14 (GCC 6.3.0)
C (GCC 5.4.0)
Java (OpenJDK 1.8.0)
Pascal (FPC 3.0.0)
Python2 (2.7.12)
Python3 (3.5.2)
Python3 (3.8.2)
C# (Mono 4.2.1)
Fortran
Perl
Ruby
Ada
SML
Visual C++
Visual C
CLang
CLang++
Theme:
Monokai
Solarized Light
Material
Share Code?
Yes
No
×
Login
Username:
Password:
Cookie:
Never
One Day
One Week
One Month
One Year
×
Register
Username:
Password:
Repeat Password:
Nickname:
School:
Email:
×
News Title
by