Fruits(翻译)

2022.2.13

题目网址:

https://codeforces.com/contest/12/problem/C

原题:

Fruits

 1000ms  262144K

描述:

The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times.

When he came to the fruit stall of Ashot, he saw that the seller hadn't distributed price tags to the goods, but put all price tags on the counter. Later Ashot will attach every price tag to some kind of fruits, and Valera will be able to count the total price of all fruits from his list. But Valera wants to know now what can be the smallest total price (in case of the most «lucky» for him distribution of price tags) and the largest total price (in case of the most «unlucky» for him distribution of price tags).

输入:

The first line of the input contains two integer number n and m (1 ≤ n, m ≤ 100) — the number of price tags (which is equal to the number of different kinds of fruits that Ashot sells) and the number of items in Valera's list. The second line contains n space-separated positive integer numbers. Each of them doesn't exceed 100 and stands for the price of one fruit of some kind. The following m lines contain names of the fruits from the list. Each name is a non-empty string of small Latin letters which length doesn't exceed 32. It is guaranteed that the number of distinct fruits from the list is less of equal to n. Also it is known that the seller has in stock all fruits that Valera wants to buy.

输出:

Print two numbers a and b (a ≤ b) — the minimum and the maximum possible sum which Valera may need to buy all fruits from his list.

翻译:

描述:

春天就要来了,这意味着许多水果将出现在柜台。一个晴朗的一天,小男孩瓦莱拉决定去购物。他把他想要买的m种水果列了一个清单。如果瓦莱拉想要买这种水果不止一个,那么他就把这个水果列在清单上好几次。

当他到了Ashot的水果贩卖处,他看见售卖者没有分配价格标签给商品,但是把所有的价格标签放在了柜台上。之后Ashot将每个价格标签都贴在一些种类的水果上,并且瓦莱拉将能够数清他清单上的所有水果的价格。但是瓦莱拉想要知道现在由他分配的价格标签来看,什么是他清单的最小开支(如果发生最幸运的事)和最大开支(如果发生最倒霉的事)。

输入:

输入的第一行包含两个整数数字n和m(1<=n,m<=100)---价格标签的数量(这与Ashot所售卖的不同种类水果的数量相等)和瓦莱拉清单上的水果的数量。第二行包含n个以空格分开的正整数。每个都不超过100,代表某种水果的价格。接下来m行包含清单中的水果名称。每个名字都是一个非空的由小写拉丁字母组成的字符串,长度不超过32.可以确保清单上不同水果的数量小于等于n。我们还知道,卖家有库存所有瓦莱拉想要买的水果。

输出:

打印出两个数字a和b(a<=b)---瓦莱拉可能需要买他清单上所有水果的最小和最大可能的总价格。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值