시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 150 | 85 | 73 | 58.400% |
Given the prices of different types of coffee (latte, cappuccino, · · ·) for each size (small, medium, and large), and a list of orders of a group of persons. Your task is to find how much will each person pay eventually. The cost that a person needs to pay is the cost of coffee he/she ordered in addition to the delivery fees. The delivery fees for each person are 100\$ divided by the number of persons (rounded down).
Eventually, the final cost should ignore 1\$ greater or less than what should be paid to the nearest multiple of 5 (i.e 44\$ and 46\$ will be rounded to 45\$. However, 47\$ and 48\$ will not be changed).
The first line of the input contains a single integer T specifying the number of test cases.
Each test case begins with a line containing two integers C and P (1 ≤ C, P ≤ 100), in which C is the number of different types of coffees, and P is the number of unique persons.
Then C lines follow, giving the coffee types. Each line contains a string N and three integers S, M, and L (1 ≤ S, M, L ≤ 100), in which N is a coffee name, S, M, and L are the prices for small, medium, and large sizes, respectively. Each coffee type will appear exactly once per test case.
Then P lines follow, giving the list of orders. Each line contains three strings X, Y , and Z, in which X is a person name, Y is the coffee size (Y ∈ {small, medium, large}), and Z is a coffee name. It is guaranteed that all the given P names are distinct, and each person will order coffee type that exists.
Both the coffee and person names are non-empty strings consisting of lowercase and uppercase English letters with a length of no more than 15 letter.
For each test case, print P lines in which each line contains two space-separated values, the name of the person and the total cost he/she will pay for his/her order. Print the persons in the same order as given in the input.
1 3 3 cappuccino 28 34 41 latte 25 31 38 flatwhite 26 33 47 Mohammed medium cappuccino Mostafa large latte Ahmad small flatwhite
Mohammed 67 Mostafa 70 Ahmad 60
The delivery fees is 100\$ and divided by 3 persons, so each of them will pay ⌊100/3⌋ = 33\$.