You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
650 B
32 lines
650 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
vector<int> a;
|
|
int c;
|
|
//获取初值
|
|
for (int i = 0; i < n; i++) {
|
|
cin >> c;
|
|
a.push_back(c);
|
|
}
|
|
|
|
bool found = false;
|
|
for (int i = 0; i < n - 1; i++) {
|
|
int xiao = 0;
|
|
int da = 0;
|
|
for (int j = i + 1; j < n; j++) {
|
|
if (a[j] > a[i])da++;
|
|
if (a[j] < a[i]) xiao++;
|
|
}
|
|
if (xiao == da) {
|
|
cout << a[i] << endl;
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found) cout << "-1" << endl;
|
|
return 0;
|
|
} |