Chef And Summer 2018
All submissions for this problem are available.
Chef is ready for Summer. His family wants to eat alot of ice creams. His family consists of N people including Chef. There are total B types of ice creams in the shop from where Chef buys. Iith ice cream's one box can satisfy Xi people at once. Unfortunately Chef can only buy atmost one box of each type of ice cream. Each member of family wants some different type of ice cream as given below. Tell whether Chef will be able to satisfy all the family members or not.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of family members and B the number of ice cream types. The second line contains B space-separated integers A1, A2, ..., AB denoting the number of people each ice cream can satisfy.
Next N line consists of following information:
Each line will start with integer X - denoting the number of types of ice cream Nith family member needs followed by X different type of ice cream types.
For each test case, output a single line containing yes or no if Chef can satisfy by buying or not.
- 1 ≤ T ≤ 100
- 1 ≤ N, B ≤ 10000
- 1 ≤ Bi ≤ 10000
- 1 ≤ X ≤ B
Input: 2 2 4 1 1 1 1 2 1 2 3 1 2 3 2 4 1 1 1 1 2 1 2 2 3 4 Output: no yes
|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, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.