joj2154

本文介绍了一种算法解决饥饿兔子分配胡萝卜的问题。通过输入篮子里的胡萝卜总数和每只兔子所需的胡萝卜数量,算法能计算出为了让大部分兔子存活而必须驱逐的最少兔子数量。

2154: Hungry Rabbits


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE
3s8192K1141400Standard
A group of hungry rabbits had got a basket of carrots, but these carrots isn't enough for all the rabbits to stay alive. So they had a meeting to solve the problem. They determined to drive off some rabbits,then the rest of them could have enough carrots. The number of carrots each rabbit required is given as a nonegetive interger v i, and there's T carrots in the basket. The chairman of rabbit association is a big beautiful and strong rabbit, he was very pity for doing this thing, and he wanted to know the least number of rabbits they would drive off to make the rest of the rabbits stay alive.

Input

There's more than one test case.In each case, there're two positive integers T and N. T stands for the number of carrots in the basket and N(1<=N<=1000) stands for the total number of the rabbits. Then following N lines each contains a nonegetive interger v i. These N intergers stand for the carrots each rabbit needed.

Output

For each test case ,output the least number of rabbits they would drive off!

Sample Input

30 5
12
14
23
4
10

Sample Output

2

Problem Source: sea


This problem is used for contest: 23 


Submit / Problem List / Status / Discuss


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值