玲珑杯-1057-Private Value【思维】【map】
来源:互联网 发布:python怎么发音 编辑:程序博客网 时间:2024/05/18 06:23
题目链接:点击打开链接
1057 - Private Value
Time Limit:1s Memory Limit:128MByte
Submissions:562Solved:192
DESCRIPTION
The "private value" is the value that occurs, but most infrequent.
An array of integers is given, and you need print the private values of the array.
Please notice that, there might be several private values, and you need print them in increasing order.
INPUT
The first line is an integer T(1 <= T <= 4), indicating the number of test cases.For each case, the first line contains an integer n (n <= 100000).The second line contains n integers a_i (0 <= a_i <= 10^9),
OUTPUT
For each case, print all private values in increasing order in a line.
SAMPLE INPUT
2
7
1 1 2 2 3 3 3
5
5 3 2 4 1
SAMPLE OUTPUT
1 2
1 2 3 4 5
大意:统计序列中出现次数最少的元素,若存在多个,则从小到大输出结果
#include<cstdio>#include<algorithm>#include<cstring>#include<map>using namespace std;int n;int a[100010];map<int,int> M;int main(){int t;scanf("%d",&t);while(t--){scanf("%d",&n);M.clear();for(int i=0;i<n;i++){scanf("%d",a+i);M[a[i]]++;}int mmin=100000;for(int i=0;i<n;i++){mmin=min(mmin,M[a[i]]);}sort(a,a+n);int top=unique(a,a+n)-a;bool flag=0;for(int i=0;i<top;i++){if(M[a[i]]==mmin){if(flag)printf(" ");printf("%d",a[i]);flag=1;}}puts("");}return 0;}
0 0
- 玲珑杯-1057-Private Value【思维】【map】
- 【玲珑学院 1057 - Private Value】+ map
- 玲珑杯 B -- Private Value
- “玲珑杯”ACM比赛 Round #5 B -- Private Value【STL-map】
- 玲珑杯-1065-思维
- 玲珑杯-1071【思维】
- Lonlife 1057 Private Value
- 玲珑杯 A 枚举 思维 数学
- 玲珑 1101(思维暴力)@
- 玲珑杯
- “玲珑杯”ACM比赛 Round #19 E.Expected value of the expression【Dp】
- 玲珑学院-1014-Absolute Defeat【思维】
- 玲珑学院OJ 1071 Boring Game【思维】
- map, value> or vector, value> >?
- 【玲珑杯 1010 Alarm】
- 玲珑杯 1010 - Alarm
- 玲珑杯-【 chess play】
- 玲珑杯-【See car】
- C语言中的函数大概执行过程
- c++::写一个通用的冒泡排序
- 老僧长谈设计模式-11-原型模式
- caffe笔记4——c++接口
- 20161217
- 玲珑杯-1057-Private Value【思维】【map】
- SqlServer安装遇到的问题几则以及解决办法
- codeforce B. Chloe and the sequence (递归)
- vi/vim基本使用方法
- 【jzoj4922】【环】
- 利用TextInputLayout实现hint浮动显示(二)
- 嵌入式开发中的细节
- 读取文件,到标准输入流(c语言 和 c++版)
- 具有单选标记的菜单;auto关键字;CheckMenuRadioItem函数