每日一题·暑假 week1
作者:互联网
3761. 唯一最小数
https://www.acwing.com/problem/content/3764/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<unordered_map>
using namespace std;
typedef long long LL;
int T;
const int N = 2e5+5;
int n;
int a[N];
unordered_map<int,int> m;
int main(){
cin >> T;
while(T--){
m.clear();
int ans = -1;
cin >> n;
for(int i = 1; i <= n; i++){
scanf("%d",&a[i]);
if(m[a[i]] != 0){
m[a[i]] = -1;
}
else {
m[a[i]] = i;
}
}
sort(a+1,a+n+1);
for(int i = 1;i <= n; i++){
if(m[a[i]] != -1){
ans = m[a[i]];
break;
}
}
cout<<ans<<endl;
}
return 0;
}
// freopen("testdata.in", "r", stdin);
标签:map,www,int,每日,cin,long,暑假,week1,include 来源: https://www.cnblogs.com/0fflineboy/p/15390613.html