QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#672. 北條的反擊

Statistics

有 $n$ 個箱子(編號 1 到 $n$)、$m$ 把鑰匙(編號 1 到 $m$)以及 $d$ 間商店(編號 1 到 $d$)。鑰匙 $i$ 可以用來開啟其中一個箱子 $a_{i,1}, \dots, a_{i,k_i}$。然而,一旦鑰匙被用來開啟箱子,它就會消失。因此,一把鑰匙不能用來開啟多個箱子。鑰匙 $i$ 在商店 $s_i$ 出售,價格為 $c_i$ 美元。Akiba 想要購買一些鑰匙並開啟所有的箱子。(他不能多次購買同一把鑰匙。)

Kitamasa 想要阻止 Akiba 這麼做。為了達成目的,他可以在 Akiba 決定購買哪些鑰匙之前,改變某些鑰匙的價格。如果他支付 $b_j$ 美元,他可以將商店 $j$ 出售的所有鑰匙價格提高 1 美元。對於每間商店,他可以重複此操作任意非負整數次:例如,如果他支付 $2b_j$ 美元,他可以將商店 $j$ 出售的所有鑰匙價格提高 2 美元。然而,例如當 $b_j = 2$ 時,他不能支付 1 美元並將價格改變 0.5 美元。

Akiba 的目標是最小化 (Akiba 的支付金額) $-$ (Kitamasa 的支付金額),而 Kitamasa 的目標是最大化該值。請計算當兩位玩家皆採取最佳策略時的該數值。如果答案可以無限大,請輸出 $-1$。題目保證若 Kitamasa 不做任何動作,Akiba 可以開啟所有箱子。

輸入格式

第一行包含三個整數 $n, m$ 和 $d$ ($1 \le m \le 1000, n \le 100, 1 \le n, d \le m$)。

接著有 $m$ 行,每行描述一把鑰匙。每行開頭為三個整數:$c_i$(鑰匙價格)、$s_i$(販售該鑰匙的商店編號)以及 $k_i$(該鑰匙能開啟的箱子數量)。接著是 $k_i$ 個整數:這些箱子的編號 ($1 \le c_i \le 1000, 1 \le s_i \le d, 1 \le k_i \le \min(10, n), 1 \le a_{i,j} \le n$,且若 $j \neq k$ 則 $a_{i,j} \neq a_{i,k}$)。

接著有 $d$ 行,每行包含一個整數 $b_i$ ($1 \le b_i \le 1000$)。

輸出格式

輸出一個整數:問題的答案。

範例

輸入格式 1

3 4 1
2 1 2 1 2
2 1 2 2 3
2 1 2 3 1
3 1 3 1 2 3
5

輸出格式 1

6

輸入格式 2

3 4 1
2 1 2 1 2
2 1 2 2 3
2 1 2 3 1
3 1 3 1 2 3
2

輸出格式 2

-1

輸入格式 3

2 3 2
3 1 2 1 2
4 1 1 2
5 2 2 1 2
1
2

輸出格式 3

8

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.