CF2126C.I Will Definitely Make It

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

I Will Definitely Make It

You are given nn towers, numbered from 11 to nn. Tower ii has a height of hih_i. At time 00, you are on the tower with index kk, and the current water level is 11.

Every second, the water level rises by 11 unit. At any moment, if the water level becomes strictly greater than the height of the tower you are on, you perish.

You have a magical ability: at moment xx, you can start teleporting from tower ii to tower jj, which will take hihj\lvert h_i - h_j \rvert seconds. That is, until moment x+hihjx + \lvert h_i - h_j \rvert, you will be on tower ii, and at moment x+hihjx + \lvert h_i - h_j \rvert, you will move to tower jj. You can start a new teleportation at the same moment you just arrived at tower jj.

For example, if n=k=4n=k=4, h=[4,4,4,2]h=[4, 4, 4, 2], then if you start teleporting from tower 44 to tower 11 at moment 00, the movement will look as follows:

Note that if the height of tower 11 were 55, you would not be able to teleport to it immediately, as you would be submerged at moment 22.

Your goal is to reach any tower with the maximum height before the water covers you.

Determine if this is possible.

Input

Each test consists of several test cases. The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1kn1051 \le k \le n \le 10^5) — the number of towers and the index of the tower you are initially on.

The second line contains nn integers h1,h2,,hnh_1, h_2, \dots, h_n (1hi1091 \le h_i \le 10^9) — the heights of the towers.

It is guaranteed that the sum of all nn across all test cases does not exceed 10510^5.

Output

For each test case, output one line: "YES", if you can reach the tower with the maximum height before the water covers you, or "NO" otherwise.

You may output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

Note

In the first test case, the only possible path is: $3 \rightarrow 2 \rightarrow 1 \rightarrow 4 \rightarrow 5$.

In the second test case, regardless of the order, it will not be possible to reach the tallest tower.

In the third test case, one of the possible paths is: 414 \rightarrow 1.

Samples

5
5 3
3 2 1 4 5
3 1
1 3 4
4 4
4 4 4 2
6 2
2 3 6 9 1 2
4 2
1 2 5 6
YES
NO
YES
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验