ZOJ-4024 Peak

https://vjudge.net/problem/ZOJ-4024

#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int h[N];
int main()
{
    
    
	int T,n;
	cin>>T;
	while(T--)
	{
    
    
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&h[i]);
		int l=1,r=n;
		while(l<n && h[l]<h[l+1]) l++;
		while(r>1 && h[r-1]>h[r]) r--;
		
		if(l==r && l>1 && l<n) cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
 } 

Guess you like

Origin blog.csdn.net/weixin_52341477/article/details/120891658