shunfurh 于 2017.09.16 12:30 提问
Angelo, the famous Italian cocktail mixer, has finally opened his new bar in Rome and is about to have his company "Angelo's Cocktail Mix" (ACM) noted at the stock exchange. In order to give the stock exchange speculators some meat, he would like to publish some statistics about what cocktails he mixes most.
Angelo has collected some data about what cocktails are ordered on a typical evening in his bar. It is your task to compute the "top ten favourite cocktails" list which features the cocktails together with their prices.This list will be published in "Gazetto dello cocktail famoso", the specialized cocktail magazine that appears in Italy on a daily basis.
The ordering criterion for the top ten is mainly how often they got mixed. If two or more cocktails have been mixed the same number of times, their position in Angelos recipe book decides which one is first.Cocktails in the top ten must have been mixed at least once.
Of course, if some drunk customer orders a cocktail which does not exist in Angelos recipe book, then he ignores the order. If the cocktail is in the book, then there is one small detail which Angelo has forgotten to tell you. He never mixes the same cocktail more than once in turn. So if Angelo gets the order for the same cocktail he has just been mixing then he will mix the next cocktail in his recipe book instead, or, for the last cocktail in his book, the first cocktail instead.
If there are not enough ingredients left to mix a cocktail, Angelo does the same (i.e., he tries the next cocktail in his book, turning to the front of the book if necessary). If there are no ingredients left to mix any cocktail in his book, he ignores the current order.
The cocktail prices can be computed by the weighted prices of their ingredients multiplied by 3 plus 10000 Lira for mixing and service.
The first line contains the number of scenarios. Scenarios are implicitly numbered starting from 1. For each scenario there are three tables:
1. Angelo's recipe book.
2. A table of ingredients.
3. A table of cocktail orders.
The recipe book consists of:
One line with the total number of cocktails in the book.
Following it, for each cocktail two lines:
The first line contains the name of the cocktail and the number of different ingredients.
The second line contains the ingredient names and their amounts in centi-liters separated by blanks.
The table of ingredients consists of:
One line containing the number of available ingredients.
For each ingredient a line containing the name, the available amount of that ingredient in centi-liters and the price in Lira per centi-liter.
Finally, the table of cocktail orders consists of:
One line containing the number of orders.
For each order the name of the cocktail.
Names of cocktails and ingredients are strings containing only alphanumeric characters or underscores (no whitespace). All values are integer values smaller which are at most 10000.
For every scenario i in the input print a line "Scenario i top cocktails:", followed by the top ten list ordered by rank 1 to 10.
For every entry in the list print a line containing the rank, name, number of times that the cocktail was mixed, and price of the cocktail each separated by a single space.
Vodka 3 Coffe_Liqueur 2 Cream 1
White_Rum 4 Cream_of_Coconut 5 Pineapple_Juice 5 Cream 1
White_Rum 4 Lemon_Juice 1 Cola 10
White_Rum 70 240
Vodka 70 120
Coffe_Liqueur 50 200
Cream_of_Coconut 20 150
Pineapple_Juice 100 40
Cream 40 20
Scenario 1 top cocktails:
1 White_Russian 2 12340
2 Pina_Collada 2 15790
- 1402. Cocktails
- 题意理解有n种酒，每次取两种不同的酒调和成新的品种，选出两种酒的调和顺序不同就算不同的品种。问一共有多少种品种？问题分析全排列数问题。计算P(N,2) + P(N,3) + ... + P(N,N). 因为计算结果非常大，所以数据类型选择long double类型，最后恢复成整数格式打印。其他long double类型比较特殊，是我知道的c++最大的可以表示的数的类型。代码链接：http://ac...
- ural 2071 - Juice Cocktails
- 题意：有n杯调和果汁，用A,B,P三种果汁调，每一次可以往一个连续区间添加一种果汁，问最少需要加多少次。 n很大，最大10的五次方，但是状态数量很有限，只有7种，相同的果汁肯定要连续放才能使添加次数最少，而且连续相同的果汁不管有多少，总是跟一杯的时候结果相同，那么直接对于七种状态全排列找最优解就行了。 代码因为时间比较紧，写的比较挫一点，可以进一步优化。 #include #include