【PAT甲级】1041 Be Unique (20 分)(多重集)

题意:

输入一个正整数N(<=1e5),接下来输入N个正整数。输出第一个独特的数(N个数中没有第二个和他相等的),如果没有这样的数就输出"None"。

AAAAAccepted code:

 1 #define HAVE_STRUCT_TIMESPEC
 2 #include<bits/stdc++.h>
 3 using namespace std;
 4 multiset<int>st;
 5 int a[100007];
 6 int main(){
 7     ios::sync_with_stdio(false);
 8     cin.tie(NULL);
 9     cout.tie(NULL);
10     int n;
11     cin>>n;
12     for(int i=1;i<=n;++i){
13         cin>>a[i];
14         st.insert(a[i]);
15     }
16     for(int i=1;i<=n;++i)
17         if(st.count(a[i])==1){
18             cout<<a[i];
19             return 0;
20         }
21     cout<<"None";
22     return 0;
23 }

 

 

 

posted @ 2019-09-26 01:40  sewage  阅读(160)  评论(0编辑  收藏  举报