提交时间:2023-01-12 15:57:54
运行 ID: 17818
#include <bits/stdc++.h> using namespace std; int a[110],n,ans; int main(){ cin>>n; for (int i=1;i<=n;i++){ cin>>a[i]; } a[n+1]=1e9; for(int i=1;i<=n;i++){ if(a[i]>a[i+1]&&a[i+1]>=a[i-1]){ for(int j=i+1;j<=n&&a[j]<a[i];j++){ ans+=a[j]!=a[j-1]; } break; } if(a[i]<a[i-1]&&a[i-1]<=a[i+1]){ for(int j=i-1;j>=1&&a[j]>a[i];j--){ ans+=a[j]!=a[j+1]; } break; } } cout<<ans; return 0; }