# [Kattis] Delicious Bubble Tea >題目連結:https://open.kattis.com/problems/bubbletea Bubble Tea is now one of the most popular drink in Vietnam. Nowadays, walking down on the street, you can find a bubble tea shop everywhere. A huge number of bubble tea brands have arrived: Bobapop, Chago, DingTea, GongCha, Mr.GoodTea, RoyalTea, ToCoToCo,… Bubble tea attracts students not only as a tasty drink, but also with various kinds of extra topping: alo vera, chocolate flan, coconut jelly, egg pudding, fruity pearl,…Ok, I will stop writing this statement here as I must get some bubble tea immediately. It is so so so addictive. :::success 珍珠奶茶現在已經成為越南最受歡迎的飲品之一。如今,在街上走一走,你隨處都能找到珍珠奶茶店。有大量的珍珠奶茶品牌出現:Bobapop、Chago、DingTea、GongCha、Mr.GoodTea、RoyalTea、ToCoToCo等等。珍珠奶茶吸引學生的不僅僅是美味的飲料,還有各種類型的配料:蘆薈、巧克力布丁、椰子果凍、蛋布丁、水果珍珠等等...好了,我在這裡停止陳述,因為我必須立刻去喝一杯珍珠奶茶。它實在是太太太上癮了。 ::: > <img src="https://open.kattis.com/problems/bubbletea/file/statement/en/img-0001.jpg" style="width:200px ; margin: 0 auto; "> > >Bubble tea >珍珠奶茶 ><img src="https://open.kattis.com/problems/bubbletea/file/statement/en/img-0002.png" style="width:200px ; margin: 0 auto; "> > >Toppings >配料 After teaching a philosophy class to Vietnamese students preparing for International Philosophy Olympiad, PVH invites his students to enjoy a cup of bubble tea. The tea shop sells $N$ kinds of tea and $M$ kinds of topping. Every kind of tea or topping has its own price. For each student, PVH will buy him a cup of tea with exactly one kind of topping. The cost of a cup equals to the cost of the tea plus the cost of the topping. However, not every kind of topping can be mixed with every kind of tea. For each kind of tea, we know the list of toppings can be mixed with. :::success 在教完一堂給準備參加國際哲學奧林匹亞競賽的越南學生的哲學課後,PVH邀請他的學生享受一杯珍珠奶茶。這家茶店提供$N$種茶和$M$種配料。每種茶或配料都有自己的價格。對於每位學生,PVH將為他買一杯只包含一種配料的茶。一杯的成本等於茶的成本加上配料的成本。然而,並不是每種茶都可以與每種配料混合。對於每種茶,我們知道可以混合的配料列表。 ::: Given the amount of money PVH has, he would like to know how many students he can invite to the party, if one student drinks exactly one cup of bubble tea. Remember, he never watches his students drinking bubble tea without drinking anything, so he must buy himself a cup of bubble tea first! :::success 鑒於PVH擁有的金額,他想知道他可以邀請多少位學生參加這個派對,如果每位學生只喝一杯珍珠奶茶。請記住,他從不看著學生喝珍珠奶茶而不喝任何東西,所以他必須先為自己買一杯珍珠奶茶! ::: ## Input * The first line contains one integer $N$ - the amount of kinds of tea the shop has. * The second line contains $N$ integers - the price of all kinds of tea. * The third line contains one integer $M$ - the amount of toppings the shop has. * The forth line contains $M$ integers - the price of all kinds of topping. * The $ith$ of the next $N$ lines describes the toppings that can be mixed with th $ith$ kind of tea. The line starts with an integer $K$, followed by $K$ integers. All these $K$ integers are in the range $[1,M]$ and pairwise different. Each integer denotes a kind of topping which can be combined with the $ith$ kind of tea. * The last line contains one integer $X$ - the amount of money PVH has. :::success * 第一行包含一個整數$N$ - 茶店提供的茶的種類數。 * 第二行包含$N$個整數 - 所有種類茶的價格。 * 第三行包含一個整數$M$ - 茶店提供的配料種類數。 * 第四行包含$M$個整數 - 所有種類配料的價格。 * 接下來的$N$行中的第$i$行描述了可以與第$i$種茶混合的配料。該行以一個整數$K$開頭,然後是$K$個整數。這$K$個整數都在範圍$[1,M]$內且互不相同。每個整數表示可以與第$i$種茶結合的一種配料。 * 最後一行包含一個整數$X$ - PVH擁有的金額。 ::: ## Output Write the maximum number of students PVH can buy bubble tea for. :::success 輸出PVH最多可以為多少位學生買珍珠奶茶。 ::: ## Constraints The amount of money is between $1$ and $109$, inclusive. All other numbers in the input files are between $1$ and $1000$, inclusive. :::success 金額在$1$到$109$之間,包括$1$和$109$。輸入文件中的所有其他數字在$1$到$1000$之間,包括$1$和$1000$。 ::: ## Sample clarification In this example, there are three kinds of tea with price 10, 20 and 30; as well as five kinds of topping with price from 1 to 5. The cheapest combination of tea and topping is the first kind of tea with the forth kind of topping, with a total cost of 14. Note that, while combining the first kind of tea with the first kind of topping gives lower price (11), it is not allowed since the first kind of tea is only combinable with toppings of kind 4 and 5. (See the $5th$ line of the input). Hence, with the amount of money of 42, PVH can buy three cups of tea, one for him and two more for his students! :::success 在這個示例中,有三種茶,價格分別為$10$、$20$和$30$,以及五種配料,價格從$1$到$5$不等。 茶和配料的最便宜組合是第一種茶和第四種配料,總成本為$14$。請注意,儘管將第一種茶與第一種配料混合可以獲得更低的價格($11$),但這是不允許的,因為第一種茶只能與第4和5種配料混合(請參閱輸入的第5行)。 因此,PVH擁有$42$的金額,他可以為三位學生購買三杯茶,其中一杯給他自己,另外兩杯給他的學生! ::: ### Sample Input 1 ``` 3 10 20 30 5 1 2 3 4 5 2 4 5 3 1 2 3 5 1 2 3 4 5 42 ``` ### Sample Output 1 ``` 2 ``` ###### 翻譯錯誤請留言告知