22A
来源:互联网 发布:淘宝守望先锋代练 编辑:程序博客网 时间:2024/05/22 08:00
Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other words it is the smallest element strictly greater than the minimum. Help Bob solve this problem.
The first input line contains integer n (1 ≤ n ≤ 100) — amount of numbers in the sequence. The second line contains n space-separated integer numbers — elements of the sequence. These numbers don't exceed 100 in absolute value.
If the given sequence has the second order statistics, output this order statistics, otherwise output NO.
41 2 2 -4
1
51 2 3 1 1
2
题意:让我们求第二小的那个数,然后输出,没有就输出NO、
题解:,由于数据很小暴力,排序后输出当前不等于前一个的术,就是的第二小的。eg:111233 ,2第一个不等于前面,第二小,输出2。
#include<bits/stdc++.h>using namespace std;int main(){ int a[110],n; while(cin>>n) { for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); for(int i=1;i<n;i++) { if(a[i]!=a[i-1]) { cout<<a[i]<<endl; return 0; } } puts("NO"); } return 0;}
- 22A
- BestCoder Round #22 A
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- A
- A*
- a
- Array Partition I
- css(五)---css中的一些问题
- 大屏、激光、人工智能,谁将成为2018彩电行业关键词?
- 男生都是如何折磨自己的女朋友的?
- Linux下的tar压缩解压缩命令详解
- 22A
- 拥有拦截器的Okhttp3封装
- 技术是没有局限
- oracle基本语句
- 10_锁重入,异常,继承,同步代码块,死锁
- python学习_实现一个考拉咨猜想
- Scala学习(九)---文件和正则表达式
- Spring Boot简介
- Linux服务器 使用tc命令对网卡流量上下行限速