Chef Feeds Cats
All submissions for this problem are available.### Read problem statements in [Hindi](http://www.codechef.com/download/translated/LTIME76/hindi/CATFEED.pdf), [Bengali](http://www.codechef.com/download/translated/LTIME76/bengali/CATFEED.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/LTIME76/mandarin/CATFEED.pdf), [Russian](http://www.codechef.com/download/translated/LTIME76/russian/CATFEED.pdf), and [Vietnamese](http://www.codechef.com/download/translated/LTIME76/vietnamese/CATFEED.pdf) 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 \le T \le 100$ - $2 \le N \le 100$ - $1 \le M \le 10^3$ ### Subtasks **Subtask #1 (100 points):** original constraints ### Example Input ``` 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 ``` ### Example Output ``` YES YES YES NO NO YES NO ``` ### Explanation **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.
|Tags||deadwing97, kingofnumbers, ltime76|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.