HBU某个专业导师想要招聘一个研究生,有n个人报名参加,这位导师通过面试确认了n个人的综合得分,然后进行选择。
因为导师只要一个人,他会选择得分最高的人,但是这个人可能不是唯一的,为了避免不公平情况发生,也不让自己为难,他会选择在没有和其他人分数相同的情况下得分最高的人录用。
求这个最高得分,如果没有合适的人,则输出−1
输入格式:
第一行一个整数n 1<=n<=100000
第二行n个整数表示每个人的面试得分
保证所有输入的数为正整数且不超过10000
输出格式:
一行一个整数表示答案
输入样例1:
在这里给出一组输入。例如:
3
3 2 1
输出样例1:
在这里给出相应的输出。例如:
3
输入样例2:
6
5 5 4 1 5 4
输出样例2:
1
输入样例3:
3
4 4 4
输出样例3:
-1
水题,逆序找即可
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define endl '\n'
#define rep(i,a,n) for (int i = a; i < n; i ++ )
#define repn(i,a,n) for (int i = a; i <= n; i ++ )
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<int,int> PII;
ll gcd(ll a,ll b) { return b ? gcd(b,a % b) : a; }
const int N = 1e6 + 10;
int cnt[N];
int main(){
int n;
cin >> n;
rep(i, 0, n){
int x; cin >> x;
cnt[x] ++;
}
for (int i = 10000; i; i -- ){
if(cnt[i] == 1) {
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}