【玲珑学院 1057 - Private Value】+ map
来源:互联网 发布:优酷mac缓存在哪里 编辑:程序博客网 时间:2024/09/21 06:18
1057 - Private Value
Time Limit:1s Memory Limit:128MByte
Submissions:511Solved:165
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
map~映射~~
#include<cstdio>#include<map>#include<algorithm>using namespace std;const int MAXN = 100010;map <int,int> m;int ma[MAXN];int main(){ int T,n; scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i = 1 ; i <= n ; i++){ scanf("%d",&ma[i]); m[ma[i]]++; } sort(ma + 1, ma + 1 + n); int minn = 1e8; for(int i = 1 ; i <= n ; i++) minn = min(minn,m[ma[i]]); int ok = 0; for(int i = 1 ; i <= n ; i++){ if(m[ma[i]] == minn){ if(ok) printf(" "); printf("%d",ma[i]); ok = 1; } m[ma[i]] = 0; // 每次用过后清空 } printf("\n"); } return 0;}
- 【玲珑学院 1057 - Private Value】+ map
- 玲珑杯-1057-Private Value【思维】【map】
- 玲珑杯 B -- Private Value
- “玲珑杯”ACM比赛 Round #5 B -- Private Value【STL-map】
- Lonlife 1057 Private Value
- 玲珑学院 1058 - Coco
- 玲珑学院problem1068
- 玲珑学院1072 【DFS】
- 玲珑学院 1097
- 玲珑学院-1107【贪心】
- 玲珑学院OJ 1126
- 玲珑学院OJ 1125
- 玲珑学院OJ 1131
- 玲珑学院1131
- 玲珑学院1129
- 玲珑学院OJ 1121
- 玲珑学院1129
- 玲珑学院OJ 1130
- Linux中tty框架与uart框架之间的调用关系剖析
- 玲珑杯 A -- A plus B
- 美女
- 数据结构--普里姆算法
- 2016.11.25
- 【玲珑学院 1057 - Private Value】+ map
- video4linux基础
- 模式识别二--分类器的性能评价
- 刽子手游戏
- 富文本(讲一个字符串中的一些文本颜色显示特别的颜色,文字中替换表情)
- Win10使用过程中问题解决笔记
- dbms_rowid
- Codeforces(738C)-Road to Cinema
- Markdown的入门简单语法