P16572 [CodeChef] CATFEED
普及-
题目描述

Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef owns $N$ cats (numbered $1$ through $N$) and he wants to feed them. There are $M$ identical cans of cat food; each can must be used to feed exactly one cat and Chef can only feed one cat at a time. Chef wrote down the order in which he wants to feed the cats: a sequence $A_{1}, A_{2}, \ldots, A_{M}$.

An order of feeding cats is fair if there is no moment where Chef feeds a cat that has already been fed strictly more times than some other cat. Help Chef — tell him if the order in which he wants to feed the cats is fair.

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $N$ and $M$.
The second line contains $M$ space-separated integers $A_{1}, A_{2}, \ldots, A_{M}$.

------ Output ------
For each test case, print a single line containing the string "YES" if the order is fair or "NO" if it is unfair.

------ Constraints ------
$1 ≤ T ≤ 100$
$2 ≤ N ≤ 100$
$1 ≤ M ≤ 10^{3}$

------ Subtasks ------
Subtask #1 (100 points): original constraints

----- Sample Input 1 ------
7
3 9
1 2 3 1 2 3 1 2 3
3 9
1 2 3 3 2 1 1 2 3
3 5
2 3 1 1 2
3 6
2 1 1 3 2 3
2 8
1 2 1 2 1 2 1 1
5 3
5 3 1
4 5
1 2 3 1 4
----- Sample Output 1 ------
YES
YES
YES
NO
NO
YES
NO
----- explanation 1 ------
Example case 4: Cat $1$ will eat twice before cat $3$ eats even once, so the order is unfair.

Example case 5: The order is unfair because cat $1$ will eat its fifth can before cat $2$ eats its fourth can.

Example case 7: The order is unfair because cat $1$ will eat twice before cat $4$ eats even once.

输入格式

见题面

输出格式

见题面

样例输入
7 3 9 1 2 3 1 2 3 1 2 3 3 9 1 2 3 3 2 1 1 2 3 3 5 2 3 1 1 2 3 6 2 1 1 3 2 3 2 8 1 2 1 2 1 2 1 1 5 3 5 3 1 4 5 1 2 3 1 4
样例输出
YES YES YES NO NO YES NO