A. How Much Does Daytona Cost?

We define an integer to be the most common on a subsegment, if its number of occurrences on that subsegment is larger than the number of occurrences of any other integer in that subsegment. A subsegment of an array is a consecutive segment of elements in the array aa.

Given an array aa of size nn, and an integer kk, determine if there exists a non-empty subsegment of aa where kk is the most common element.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1≤t≤10001≤t≤1000) — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers nn and kk (1≤n≤1001≤n≤100, 1≤k≤1001≤k≤100) — the number of elements in array and the element which must be the most common.

The second line of each test case contains nn integers a1a1, a2a2, a3a3, ……, anan (1≤ai≤1001≤ai≤100) — elements of the array.

Output

For each test case output "YES" if there exists a subsegment in which kk is the most common element, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer). 

Example

Input

7
5 4
1 4 3 4 1
4 1
2 3 4 4
5 6
43 5 60 4 2
2 5
1 5
4 1
5 3 3 1
1 3
3
5 3
3 4 1 5 5

output 

 YES
NO
NO
YES
YES
YES
YES

Code

#include <iostream>
#include <vector>

int main() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);

    int t;
    std::cin >> t;
    while (t--) {
        int n, k;
        std::cin >> n >> k;

        bool found = false;
        for (int i = 0; i < n; i++) {
            int x;
            std::cin >> x;
            if (x == k) {
                found = true;
            }
        }
        std::cout << (found ? "YES\n" : "NO\n");
    }

    return 0;
}

Conclusion

        当我们运行这段代码时,它首先从标准输入读取一个整数 t,表示要处理的测试用例数量。接下来,它会依次处理每个测试用例。每个测试用例由两个整数 n 和 k 组成,分别表示数组的大小和目标值。
        在每个测试用例中,代码会先将布尔变量 found 初始化为 false,用来跟踪是否找到了目标值 k。然后,使用一个循环从输入中读取 n 个整数,这些整数表示数组中的元素。在循环中,它会检查当前读取的元素是否等于目标值 k,如果相等,则将 found 设置为 true,表示找到了目标值。
        处理完一个测试用例后,代码会根据 found 的值输出 "YES" 或 "NO",表示是否在该测试用例中找到了目标值。这样,代码会依次处理所有的测试用例。
        总的来说,这段代码实现了一个简单的线性搜索算法,用于判断每个测试用例中是否存在目标值。它使用循环和条件判断来进行遍历和比较,并根据结果输出相应的信息。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向阳而生__

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值