QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 2048 MB Puntuación total: 100

#15928. 露天开采

Estadísticas

露天开采(Open-pit mining)是一种通过从露天矿坑或采掘场中清除岩石或矿物来从地球中提取它们的地表开采技术。当在接近地表的地方发现具有商业价值的矿物或岩石矿床时,就会使用露天矿。自动计算机采矿公司(ACM)是一家希望通过露天开采来最大化其利润的公司。ACM 雇佣你编写一个程序,在给定一块土地描述的情况下,确定其可以获得的最大利润。

每块土地都被建模为一组材料块。从土地中挖掘块 $i$ 具有相关的价值($v_i$)以及成本($c_i$)。某些块会阻碍或掩埋其他块。例如,如果块 $i$ 被块 $j$ 和 $k$ 阻碍,那么在挖掘块 $i$ 之前,必须先挖掘块 $j$ 和 $k$。当一个块没有其他块阻碍它时,它就可以被挖掘。

输入格式

输入的第一行是一个整数 $N$($1 \le N \le 200$),表示块的数量。这些块的编号为 $1$ 到 $N$。

接下来有 $N$ 行描述这些块。第 $i$ 行描述块 $i$,以两个整数 $v_i, c_i$ 开始,分别表示第 $i$ 个块的价值和成本($0 \le v_i, c_i \le 200$)。

然后,该行上的第三个整数 $0 \le m_i \le N - 1$ 表示块 $i$ 阻碍的块的数量。紧接着是 $m_i$ 个互不相同的、用空格分隔的介于 $1$ 到 $N$ 之间(但不包括 $i$)的整数,表示块 $i$ 所阻碍的块的编号。

你可以假设存在某种挖掘顺序,使得可以挖掘出每一个块。所有块 $i$ 的 $m_i$ 之和最多为 $500$。

输出格式

输出一个整数,表示 ACM 从给定的土地中可以获得的最大利润。

样例

样例输入 1

5
0 3 2 2 3
1 3 2 4 5
4 8 1 4
5 3 0
9 2 0

样例输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.