#QHD0000059. Bữa điểm tâm dim sum (Let's Yum Cha!)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bữa điểm tâm dim sum (Let's Yum Cha!)
Let's Yum Cha!
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
You and friends go to a dim sum restaurant. There are people and types of dishes. Each type has a price and each person assigns an integer favour score between and .
Ordering one plate of type adds the sum of all favour scores for that type to the group's total favour value. Ordering two plates doubles its contribution. Maximize the mean favour value, namely the total favour over all ordered plates divided by .
No type may be ordered more than twice, no more than plates may be ordered in total, and each person pays at most . The group therefore has a total payment limit of . In addition to the dishes, every person pays a fixed tea charge of . A service charge equal to 10% of the combined dish prices and tea charges, rounded up using the ceiling function (an already integer charge stays unchanged), is added to the bill.
Choose the number of plates of each type to maximize the mean favour while respecting every constraint. You need not use the entire budget or the entire plate allowance.
Input
The first line contains . Each of the next lines starts with dish price followed by exactly favour scores, one for you and one for each of your friends.
Output
Print the optimal mean favour value with exactly two digits after the decimal point. Test data guarantees at least one affordable nonempty selection with positive favour.
Subtasks
-
Subtask 1 (20 points): , , , , and for all dishes and people; at least one dish has positive total favour and satisfies .
-
Subtask 2 (30 points): , , , , and for all ; at least one positive-favour dish meets .
-
Subtask 3 (50 points): , , , , and for all ; at least one positive-favour dish meets .
Examples
Input
3 10 5 2
6 7 5 6 9
10 9 10 10 8
Output
16.00
Explanation
There are people, so the total budget is and the tea charge is . Dish 1 costs and contributes favour points. Dish 2 costs and contributes . Ordering one of each costs before service; the service charge is , so the bill is exactly . The favour sum is , yielding an average of 16.00. Two plates of dish 2 would cost including tea and service, exceeding the budget.