All submissions for this problem are available.
Lex Luthor wants to hire a few interns for his company, Lexcorp. Each intern has a positive quality value and each is an expert in a few sub-areas of Computer Science. Lex wants to select the interns such that each field has atmost one intern, who is an expert in that field and the sum of quality over all the interns is maximised. Help Lex find the interns that may help him defeat Superman.
The number of fields is equal to the number of interns and numbered from 1 to n(if n is number of interns)
The first line contains the number of test cases, t.
- For each test cases, the first line contains a single integer, the number of interns, n
- The second line contains n integers, denoting the quality values of the interns.
- The next n lines contain a number, k which denotes the number of sub-areas of expertise of that intern follwed by k distinct numbers denoting areas
For each test case, print the optimal sum of the quality of interns.
- Sum of k over all test cases is lesser than 2e5
Input: 1 2 1 2 1 1 1 1 Output: 2
|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, SCALA, 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, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions