시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB111100.000%

문제

After falling for a large number of fake get-rich-quick schemes, Marika is in serious need for cash, and really needs a get-rich-quick scheme. Instead of listenting to the ideas of strangers, Marika asked her mathematically talented friend David for some help. David suggested the following scheme, based on a feature of certain credit cards, called cashback.

Cashback means that you earn a certain percentage of cash back on purchase you make, depending on the type of purchase. Formally, there are $n$ categories of merchandise. If you purchase merchandise from category $i$ for $x$ SEK, you earn $p_i \cdot x$ SEK back, up to some maximum limit $m_i$ in a single month. While this does not help you earn money (since $p_i < 1$), you realized that you can simply return any products you bought to the store to get the money back.

Things are made more difficult by the fact that a particular store will get suspicious if you return too many products per month. In store $i$, you can buy and return merchandise for at most $a_i$ SEK before start refusing you as a customer. Furthermore, a particular store only sells merchandise from a set of categories specific to that store. However, it has products costing any real amount of money from each category.

In order to get-rich-quick, Marika wants to earn as much money per month as possible. How much can she earn if she plans her purchases optimally?

입력

The input consists of:

  • one line with the integer $n$ ($1 \le n \le 300$), the number of categories.
  • $n$ lines with the integers $p_i$ and $m_i$ ($0 \le p_i < 100$, $0 \le m_i \le 10^9$), the cashback rate (in percent) and the maximum limit of a product. The $i$'th line contains the rate and limit of the $i$'th product.
  • one line with the integer $s$ ($1 \le s \le 300$), the number of stores.
  • $s$ lines with the integers $l_i$ and $a_i$, followed by $a_i$ distinct integers $k_{i,1}, \dots, k_{i, a_i}$, ($1 \le l_i \le 10^9$, $1 \le a_i \le n$, $1 \le k_{i, j} \le n$) The integers $k_{i, j}$ on the $i$'th line are the numbers of the categories sold by the $i$'th store. The categories are numbered between $1$ and $n$ in the order they are listed in the input.

출력

Output the maximum amount of money Marika can earn per month if purchasing items optimally. Your answer will be considered correct if it has a relative or absolute error of at most $10^{-6}$.

예제 입력 1

3
10 100
20 50
15 40
5
20 3 1 2 3
20 2 2 3
20 1 2
20 1 3
20 2 1 2

예제 출력 1

17

출처

Contest > Swedish Coding Cup > LTH Challenge 2017 G번

  • 문제를 만든 사람: Johan Sannemo