五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1759B - Lost Permutation

2023-07-05 15:08 作者:您是打尖兒還是住店呢  | 我要投稿

A sequence of n numbers is called a permutation if it contains all integers from 1 to n exactly once.

For example, the sequences [3,1,4,2], [1] and [2,1] are Permutations, but [1,2,1], [0,1] and [1,3,4] — are not.


Polycarp lost his favorite permutation and found only some of its elements — the numbers b1,b2,…bm.

He is sure that the sum of the lost elements equals s.

Determine whether one or more numbers can be appended to the given sequence b1,b2,…bm

?such that the sum of the added numbers equals s, and the resulting new array is a permutation?


Input

The first line of input contains a single integer t (1≤t≤100) —the number of test cases.


Then the descriptions of the test cases follow.


The first line of each test set contains two integers m and s (1≤m≤50, 1≤s≤1000)

—-the number of found elements and the sum of forgotten numbers.


The second line of each test set contains m different integers b1,b2…bm (1≤bi≤50)

?— the elements Polycarp managed to find.


Output

Print t lines, each of which is the answer to the corresponding test set.

?Print as the answer YES if you can append several elements to the array b,

? that their sum equals s and the result will be a permutation. Output NO otherwise.


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


Example

input

5

3 13

3 1 4

1 1

1

3 3

1 4 2

2 1

4 3

5 6

1 2 3 4 5

output

YES

NO

YES

NO

YES

Note

In the test case of the example, m=3,s=13,b=[3,1,4].

You can append to b the numbers 6,2,5, the sum of which is 6+2+5=13.

?Note that the final array will become [3,1,4,6,2,5], which is a permutation.


In the second test case of the example, m=1,s=1,b=[1]. You cannot append one or more numbers to [1]

?such that their sum equals 1 and the result is a permutation.


In the third test case of the example, m=3,s=3,b=[1,4,2]. You can append the number 3 to b.

?Note that the resulting array will be [1,4,2,3], which is a permutation.


-------------------------------------------------

用循環(huán)去處理,一個是從1遞增的一個變量,如果在數(shù)組中,那么數(shù)組減去這個值,變量加1,數(shù)組往后移動一位,如果不在數(shù)組中,則s值減去這個值,依次循環(huán)到數(shù)組結(jié)束,

如果此時s還大于0,繼續(xù)-i,然后i++,如果最后s正好等于零,那么說明是可以的,不等于零,就不可以,輸出即可。

CF 1759B - Lost Permutation的評論 (共 條)

分享到微博請遵守國家法律
含山县| 西青区| 高青县| 麻栗坡县| 盐津县| 聂荣县| 黎城县| 温泉县| 扎赉特旗| 新化县| 海伦市| 乳山市| 吴堡县| 平乡县| 富裕县| 阳谷县| 水富县| 锦屏县| 平泉县| 永济市| 浦北县| 石屏县| 青铜峡市| 阜城县| 鄱阳县| 竹溪县| 普宁市| 会宁县| 陵川县| 宜春市| 亳州市| 宣恩县| 弋阳县| 明溪县| 建平县| 板桥市| 色达县| 资兴市| 珲春市| 巨鹿县| 乌拉特后旗|