Logo
(追記) (追記ここまで)

19379번 - Kitamasa's Counterattack 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB1411872.727%

문제

There are $n$ boxes (numbered 1ドル$ through $n$), $m$ keys (numbered 1ドル$ through $m$), and $d$ shops (numbered 1ドル$ through $d$). The key $i$ can be used to open one of the boxes $a_{i,1}, \ldots, a_{i,k_i}$. However, once a key is used to open a box, it disappears. Thus, a key can't be used to open multiple boxes. The key $i$ is sold at the shop $s_i,ドル and its price is $c_i$ dollars. Akiba wants to buy some keys and open all the boxes. (He can't buy the same key multiple times.)

Kitamasa wants to prevent Akiba from doing this. In order to do it, he can change the prices of some keys before Akiba decides which keys to buy. If he pays $b_j$ dollars, he can increase the prices of all keys sold at the shop $j$ by one dollar. For each shop, he can repeat this any non-negative integer number of times: for example, if he pays 2ドル b_j$ dollars, he can increase the prices of all keys sold at the shop $j$ by two dollars. However, for example when $b_j = 2,ドル he can't pay 1ドル$ dollar and change the prices by 0ドル.5$ dollars.

Akiba's objective is to minimize the value (Akiba's payment) $-$ (Kitamasa's payment), and Kitamasa's objective is to maximize it. Compute this value when the two players play optimally. If the answer can be infinitely large, print $-1$. It is guaranteed that if Kitamasa does nothing, Akiba can open all boxes.

입력

The first line of input contains three integers $n,ドル $m,ドル and $d$ (1ドル \le m \le 1000,ドル $n \le 100,ドル 1ドル \le n, d \le m$).

Then $m$ lines follow, each describing one key. Each line starts with three integers: $c_i,ドル the price of the key, $s_i,ドル the number of the shop where the key is sold, and $k_i,ドル the number of boxes this key can open. Then $k_i$ integers follow: the numbers of these boxes (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,ドル and if $j \ne k,ドル $a_{i,j} \ne a_{i,k}$).

Then $d$ lines follow, each containing one integer $b_i$ (1ドル \le b_i \le 1000$).

출력

Print one integer: the answer to the problem.

제한

예제 입력 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

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 3: Japanese Contest, Head of Republic of Karelia Cup, Round I J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /