Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<vector>
  4. #define max 100000
  5. typedef unsigned long long int ull;
  6. using namespace std;
  7. int main()
  8. {
  9.     int t,i,j;
  10.     unsigned long int n;
  11.     ull ar[max];
  12.     pair<vector<ull>::iterator,vector<ull>::iterator> bounds;
  13.     cin>>t;
  14.     while(t--)
  15.     {
  16.               cin>>n;
  17.               for( i=0;i<n;i++)
  18.               {
  19.                       cin>>ar[i];
  20.               }
  21.            
  22.              vector<ull> v(ar,ar+n);
  23.               sort (v.begin(), v.end());
  24.               for(j=0;j<n;j++)
  25.               {
  26.               bounds=equal_range (v.begin(), v.end(), ar[j]);
  27.               if(((bounds.second-v.begin())-1)==(bounds.first-v.begin()))
  28.               {
  29.               cout<<ar[j]<<"\n";
  30.               break;
  31.               }
  32.               }
  33.      }
  34.      return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement