'commit'
This commit is contained in:
32
TangDou/XiTi/1324.cpp
Normal file
32
TangDou/XiTi/1324.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user