#P11096. [2016杭电多校]Less Time, More profit
[2016杭电多校]Less Time, More profit
Less Time, More profit
Problem Description
The city planners plan to build N plants in the city which has M shops. Each shop needs products from some plants to make profit of units. Building ith plant needs investment of units and it takes days. Two or more plants can be built simultaneously, so that the time for building multiple plants is maximum of their periods(). You should make a plan to make profit of at least L units in the shortest period.
Input
First line contains T, a number of test cases. For each test case, there are three integers N, M, L described above. And there are N lines and each line contains two integers , (1<= i <= N). Last there are M lines and for each line, first integer is , and there is an integer k and next k integers are index of plants which can produce material to make profit for the shop. 1 <= T <= 30 1 <= N, M <= 200
Output
For each test case, first line contains a line “Case #x: t p”, x is the number of the case, t is the shortest period and p is maximum profit in t hours. You should minimize t first and then maximize p. If this plan is impossible, you should print “Case #x: impossible”
Sample Input
2
1 1 2
1 5
3 1 1
1 1 3
1 5
3 1 1
Sample Output
Case #1: 5 2
Case #2: impossible
Author
金策工业综合大学(DPRK)
Source
2016 Multi-University Training Contest 9