Topic Information
1041. Be Unique (20)
Time limit (MS)
Memory Limit 65536 KB
Code length limit 16000 B
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 (<=10^5) 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
Thinking of solving problems
Record the number of occurrences of each count, the first one that appears once for the request
AC Code
#include <cstdio>#include <map>#include <vector>using namespace STD;intMain () {intN, T; vector<int>V map<int, int>mpscanf("%d", &n); for(inti =0; I < n; ++i) {scanf("%d", &t); V.push_back (t); mp[t]++; }BOOLFlag =false; for(inti =0; I < v.size (); ++i) {if(Mp[v[i]] = =1){printf("%d\n", V[i]); Flag =true; Break; } }if(!flag) {printf("none\n"); }return 0;}
1041. Be Unique (20) "Water problem"--pat (Advanced level) practise