-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path686B.cpp
More file actions
44 lines (43 loc) · 871 Bytes
/
686B.cpp
File metadata and controls
44 lines (43 loc) · 871 Bytes
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>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
int arr[n+1];
memset(arr,0,sizeof(arr));
vector<pair<int,int>>v;
int c;
for (int i = 0; i < n; i++)
{
scanf("%d", &c);
arr[c]++;
v.push_back({c,i});
}
// sort(arr,arr+n);
int d = -1;
for (int i = 0; i <= n; i++)
{
if(arr[i]==1){
d = i;
break;
}
}
if(d==-1){
printf("%d\n",d);
continue;
}
int ans;
for (int i = 0; i < v.size(); i++)
{
if(v[i].first==d){
ans = v[i].second;
}
}
printf("%d\n",ans+1);
}
}