1041. Be Unique (20) time limit MS Memory limit 65536 KB code length limit 16000 B procedure StandardAuthor Chen, Yue
Being unique is, important to people on Mars, even their lottery is designed in a unique. The rule of winning is simple:one bets on a number chosen from [1, 104]. The first one who bets on a unique number wins. For example, if there is 7 people betting on 5 to 5, then the second one who bets on wins.
Input Specification:
Each input file contains the one test case. Each case contains a line which begins with a positive an integer n (<=105) and then followed by N bets. The numbers is separated by a space.
Output Specification:
For each test case, print the winning number in a line. If There is no winner, print "None" instead.
Sample Input 1:
7 5 31 5 88 67 88 17
Sample Output 1:
31
Sample Input 2:
5 888 666 666 888 888
Sample Output 2:
None
Submit Code
1#include <cstdio>2#include <algorithm>3#include <iostream>4#include <cstring>5#include <queue>6#include <vector>7#include <cmath>8#include <string>9#include <map>Ten#include <Set> One using namespacestd; A intnum[10005]; - intMain () { - intN; thescanf"%d",&n); -memset (NUM,0,sizeof(num)); -vector<int>v; - intIinch; + for(i=0; i<n;i++){ -scanf"%d",&inch); +num[inch]++; AV.push_back (inch); at } - for(i=0; I<v.size (); i++){ - if(num[v[i]]==1){ - Break; - } - } in if(i==v.size ()) { -printf"none\n"); to } + Else{ -printf"%d\n", V[i]); the } * return 0; $}
pat1041. Be Unique (20)