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.
23 lines
522 B
23 lines
522 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n, a[1000086], ans;
|
|
|
|
int main() {
|
|
cin >> n;
|
|
a[0] = -1;
|
|
a[n + 1] = -1;
|
|
for (int i = 1; i <= n; i++) {
|
|
cin >> a[i];
|
|
if (a[i] == a[i - 1]) {
|
|
i--;
|
|
n--;
|
|
}//没错这是去重。如果重复了,总个数直接减。
|
|
}
|
|
for (int i = 3; i <= n - 2; i++)//第1、2和倒数第1、2个绝对不是低洼地。
|
|
{
|
|
if (a[i] < a[i - 1] && a[i] < a[i + 1])ans++;
|
|
}
|
|
cout << ans;
|
|
return 0;
|
|
} |