-
Notifications
You must be signed in to change notification settings - Fork 0
/
1041.cpp
66 lines (55 loc) · 815 Bytes
/
1041.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <cstdio>
#include <iostream>
using namespace std;
struct Hash
{
int count = 0;
int order = 0;
};
Hash hashTable[10001];
int main()
{
int n;
scanf("%d", &n);
int order = 0;
for (int i = 0; i < n; i++)
{
int num;
scanf("%d", &num);
// 第一次读入则记录读取顺序
if (hashTable[num].count == 0)
{
order++;
hashTable[num].order = order;
hashTable[num].count++;
}
else
{
hashTable[num].count++;
}
}
bool flag = false;
int minOrder = 10000000;
int result = 0;
for (int i = 1; i <= 10000; i++)
{
if (hashTable[i].count == 1)
{
flag = true;
if (hashTable[i].order < minOrder)
{
minOrder = hashTable[i].order;
result = i;
}
}
}
if (flag == false)
{
printf("None\n");
}
else
{
printf("%d\n", result);
}
return 0;
}