#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a;
while (n--) {
int t;
cin >> t;
a.push_back(t);
}
sort(a.begin(), a.end());
int cnt1 = 0, cnt2 = 0;
for (int i = 0; i < a.size(); i++) {
if (a[i] > a.at(a.size() / 2)) {
cnt1++;
} else if (a[i] < a.at(a.size() / 2)) {
cnt2++;
}
}
if (cnt1 == cnt2) {
cout << a.at(a.size() / 2) << endl;
} else {
cout << -1 << endl;
}
return 0;
}
201612-1 中间数
最新推荐文章于 2023-03-14 09:32:25 发布