{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e题意:有n道题目,每道题目有两个值,a,b。若 你在 t 分钟时做了某道题,那么你会获得 a * t + b的分数。但是做某道题时,有限制条件,你想要先做完了另外一些题目才能做这道题。比如 在做第三题时,第三题要求必须先做完第一题和 第二题,那么你要想做第三题 必须先做完第一题和第二题,问如何做题才能最后分数最大。\n\u003c/p\u003e\n\u003cp\u003eDlsj is competing in a contest with $n (0 \u0026lt; n \\le 20)$ problems. And he knows the answer of all of these problems.\u003c/p\u003e\n\u003cp\u003eHowever, he can submit $i$-th problem if and only if he has submitted (and passed, of course) $s_i$ problems, the $p_{i, 1}$-th, $p_{i, 2}$-th, $...$, $p_{i, s_i}$-th problem before.$(0 \u0026lt; p_{i, j} \\le n,0 \u0026lt; j \\le s_i,0 \u0026lt; i \\le n)$ After the submit of a problem, he has to wait for one minute, or cooling down time to submit another problem. As soon as the cooling down phase ended, he will submit his solution (and get \"Accepted\" of course) for the next problem he selected to solve or he will say that the contest is too easy and leave the arena.\u003c/p\u003e\n\u003cp\u003e\"I wonder if I can leave the contest arena when the problems are too easy for me.\"\u003cbr\u003e\n \"No problem.\"\u003cbr\u003e\n —— CCF NOI Problem set\u003c/p\u003e\n\u003cp\u003eIf he submits and passes the $i$-th problem on $t$-th minute(or the $t$-th problem he solve is problem $i$), he can get $t \\times a_i + b_i$ points. $(|a_i|, |b_i| \\le 10^9)$.\u003c/p\u003e\n\u003cp\u003eYour task is to calculate the maximum number of points he can get in the contest.\u003c/p\u003e\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eThe first line of input contains an integer, $n$, which is the number of problems.\u003c/p\u003e\n\u003cp\u003eThen follows $n$ lines, the $i$-th line contains $s_i + 3$ integers, $a_i,b_i,s_i,p_1,p_2,...,p_{s_i}$as described in the description above.\u003c/p\u003e\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eOutput one line with one integer, the maximum number of points he can get in the contest.\u003c/p\u003e\n\u003ch3\u003eHint\u003c/h3\u003e\n\u003cp\u003eIn the first sample.\u003c/p\u003e\n\u003cp\u003eOn the first minute, Dlsj submitted the first problem, and get $1 \\times 5 + 6 \u003d 11$ points.\u003c/p\u003e\n\n\u003cp\u003eOn the second minute, Dlsj submitted the second problem, and get $2 \\times 4 + 5 \u003d 13$ points.\u003c/p\u003e\n\u003cp\u003eOn the third minute, Dlsj submitted the third problem, and get $3 \\times 3 + 4 \u003d 13$ points.\u003c/p\u003e\n\u003cp\u003eOn the forth minute, Dlsj submitted the forth problem, and get $4 \\times 2 + 3 \u003d 11$ points.\u003c/p\u003e\n\u003cp\u003eOn the fifth minute, Dlsj submitted the fifth problem, and get $5 \\times 1 + 2 \u003d 7$ points.\u003c/p\u003e\n\u003cp\u003eSo he can get $11+13+13+11+7\u003d55$ points in total.\u003c/p\u003e\n\u003cp\u003eIn the second sample, you should note that he doesn\u0027t have to solve all the problems.\u003c/p\u003e\n"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\n5 6 0\n4 5 1 1\n3 4 1 2\n2 3 1 3\n1 2 1 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e55\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n-100 0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}}]}