编程介的小学生 2018-11-28 08:44 采纳率: 20.5%
浏览 1086
已采纳

用程序计算并且输出最大的数,一行输出一个

Problem Description
When we were a child, we all had a beautiful dream, time flies, where is your colorful dream living in now?
Get it? If not, it doesn’t matter, today is your lucky day, our kindly angel cast some items, if you get more than m different kind of items, you will get the gift of the angel: help you achieve your childhood dream.
Now we know the number of each item, find the maximum number of people who can achieve their dreams.

Input
There are several test cases in the input.
The first line of each case contains two integer n (0 < n <= 100) and m (0 < m <= n), indicating the items’ kind number and the least different kind number of items you need collect to achieve your dream.
The n integer follows, indicating number of each item, you can assume the range of items’ number is in 1 - 1 000 000 000.
The input terminates by end of file marker.

Output
For each test case, output the maximum number of people who can achieve their dreams.

Sample Input
2 2
3 5
3 2
2 2 2

Sample Output
3
3

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-02-14 23:31
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大