P26147 [AtCoder] [ARC031D] Shopping Expert
省选
题目描述

Problem Description

Takahashi is addicted to a game. In this game, you gain experience points by fulfilling certain combinations of items. Given the prices of items and a list of experience points obtainable by combinations of items, please choose items wisely to maximize the ratio of "experience points gained ÷ money spent". Note that you must buy at least one type of item, and having one of each type is sufficient to gain the experience points.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ S1 $ $ S2 $ ... $ SN $ $ T1 $ $ T2 $ ... $ TM $ $ K1 $ $ A1,1 $ $ A1,2 $ ... $ A1,K1 $ $ K2 $ $ A2,1 $ $ A2,2 $ ... $ A2,K2 $ : $ KN $ $ AN,1 $ $ AN,2 $ ... $ AN,KN $

  • The first line contains the number of experience point combinations $N\ (1≦N≦100)$ and the number of item types $M\ (1≦M≦100)$, separated by spaces.
  • The second line contains the experience points obtainable $Si\ (1≦Si≦100)$.
  • The third line contains the prices of items $Ti\ (1≦Ti≦100)$.
  • The next $ N $ lines contain the number of item types in each experience point combination $Ki\ (1≦Ki≦10)$ and $ Ki $ integers representing the item numbers $Ai,j\ (1≦Ai,j≦M,\ Ai,j\ <\ Ai,j+1)$, all separated by spaces.

Output Format

Output the maximum value of "experience points gained ÷ money spent". Absolute or relative errors within 10−4 are acceptable. End your output with a newline.

Sample Input and Output

Sample Input #1

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

Sample Output #1

1

Sample Input #2

5 5
7 1 3 6 6
6 3 2 6 5
1 2
2 2 3
4 1 2 4 5
2 2 4
2 2 3

Sample Output #2

2.8

Notes/Hints

Partial Points

This problem has two datasets, each with partial points:

  • If you solve dataset 1 with $ N≦10 $, you will be awarded 50 points.
  • If you solve dataset 2 without additional constraints, you will be awarded another 50 points separately from the above dataset.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 4 4 3 2 4 2 1 10 2 1 2 2 1 3 3 2 3 4
样例输出
1