我们记比k大为1,小于为-1,所以当连续三个数和大于0时说明可以~。
然后就还有一些特判。。看代码。。
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#include<unordered_map>
using namespace std;
#define LL long long
#define eps (1e-9)
typedef unsigned long long ull;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const int bas = 131;
const LL mod = 1e6 + 3;
int a[maxn];
int b[maxn];
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, k;
scanf("%d%d", &n, &k);
int f1 = 0, f2 = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
if (a[i] == k)f1 = 1;
if (a[i] >= k)b[i] = 1;
else b[i] = -1;
}
for (int i = 1; i <= n; i++)b[i] += b[i - 1];
if (b[2] > 0)f2 = 1;//特判两个数的情况
for (int i = 3; i <= n; i++)
{
if ((b[i] - b[i - 3]) > 0)f2 = 1;
}
if (f1 && (f2 || n == 1))printf("YES\n");//注意只有一个数时
else printf("NO\n");
}
return 0;
}