CF417D.Cunning Gena
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena x__i rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least k__i monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
一个名叫格纳的男孩非常想进入“俄罗斯编程杯”(Russian Code Cup)总决赛,或者至少得到一件T恤。但比赛提供的题目过于复杂,于是他与自己的 n 个朋友达成协议,请他们代为解题。
本次竞赛共提供 m 道题目。对于每个朋友,格纳都知道他能解决哪些题目。但格纳的朋友们不会无偿帮忙:第 i 个朋友要求格纳支付 xi 卢布,作为其解决所有他能胜任的题目的报酬。此外,该朋友仅在格纳的电脑至少连接了 ki 台显示器的前提下,才同意为其编写代码;而每台显示器的价格为 b 卢布。
格纳十分节俭,因此希望以最少的花费解决全部题目。请帮助格纳,告诉他如何花费最少的钱。初始状态下,格纳的电脑未连接任何显示器。
输入格式
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2_n_ lines describe the friends. Lines number 2_i_ and (2_i_ + 1) contain the information about the i-th friend. The 2_i_-th line contains three integers x__i, k__i and m__i (1 ≤ x__i ≤ 109; 1 ≤ k__i ≤ 109; 1 ≤ m__i ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2_i_ + 1)-th line contains m__i distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
第一行包含三个整数 n、m 和 b(1 ≤ n ≤ 100;1 ≤ m ≤ 20;1 ≤ b ≤ 109)——分别表示 Gena 的朋友人数、题目总数以及单台显示器的成本。
接下来的 2n 行描述了这些朋友的信息。第 2i 行和第 (2i+1) 行包含关于第 i 位朋友的信息。第 2i 行包含三个整数 xi、ki 和 mi(1 ≤ xi ≤ 109;1 ≤ ki ≤ 109;1 ≤ mi ≤ m),分别表示该朋友期望获得的金额、所需显示器数量,以及该朋友能解决的题目数量。第 (2i+1) 行包含 mi 个互不相同的正整数——表示第 i 位朋友能够解决的题目编号(题目编号从 1 到 m)。
输出格式
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
输出Gena解决所有问题所需的最少花费金额;如果无法实现,则输出-1。
输入输出样例
输入#1
2 2 1 100 1 1 2 100 2 1 1
输出#1
202
输入#2
3 2 5 100 1 1 1 100 1 1 2 200 1 2 1 2
输出#2
205
输入#3
1 2 1 1 1 1 1
输出#3
-1
输入解题思路,AI测评打分。不知道怎么写?