-
Notifications
You must be signed in to change notification settings - Fork 6
/
extran.cpp
44 lines (38 loc) · 885 Bytes
/
extran.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
#include<bits/stdc++.h>
#define MAX 1000000
#define ll long long
#define DEBUG(x) do { std::cout << #x << ": " << x << " "; } while (0)
using namespace std;
int main()
{
long long t,n,a[MAX],i,j,ans;
//t=1;
cin>>t;
while(t--){
cin>>n;
for(int i=0;i<n;++i){
cin>>a[i];
}
sort(a,a+n);
for(i=1;i<n-1;++i){
if(a[i+1]-a[i-1]==1 && a[i]-a[i-1]==1)
{
ans=i;
break;
}
else if(a[i]-a[i-1]==1 && a[i+1]-a[i]!=1)
{
ans=i+1;
//DEBUG(i);DEBUG(ans);
break;
}
else if(a[i+1]-a[i]==1 && a[i]-a[i-1]!=1)
{
ans=i-1;
break;
}
}
cout<<a[ans]<<endl;
}
return 0;
}