首页 > 其他 > 详细

Orac and Medians CodeForces - 1350D 思维

时间:2020-05-13 15:16:15      阅读:52      评论:0      收藏:0      [点我收藏+]
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N],n,k;
void solve()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	int f2=0;
	int f1=0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]==k)
			f1=1;
		//只要存在两个相邻的大于等于k的 就可以一直扩展 
		//细节 
		if(i<=n-1 && a[i]>=k && a[i+1]>=k )
			f2=1;
		//或者存在两个 左右是大于等于的k  那么中间的也就可以变成>=k,然后可以延申了 
		//细节 
		if(i<n-1 && a[i]>=k && a[i+2]>=k)
			f2=1;
	}
	//				细节 
	if((f1&&f2) || (n==1 && a[1]==k))
		cout<<"yes"<<endl;
	else
		cout<<"no"<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
		solve();
	return 0;
}

Orac and Medians CodeForces - 1350D 思维

原文:https://www.cnblogs.com/QingyuYYYYY/p/12882078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!