• [G] How to Get Most

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Because of the excellent performance of match,zero wants to buy some prizes.When he comes to a shop,there

    are many of the goods.But zero can not take so many,because his load is limited.So he wants to take as many as

    he can take but the sum of these things can not over his load.Now,he needs your help to judge how can he choose.

  • 输入
  • Input until EOF.
    First input two positive integers M (0<M<10000) and N (0<N<100).M means the limit of zero's load.N means the number of goods.
    Next line follows N positive integers X (0<X<10000) means the weight of this good.
  • 输出
  • One line one output.Please output the maximum number of goods he can get.
  • 样例输入
  • 100 5
    50 45 30 20 10
  • 样例输出
  • 3
  • 提示
  • 来源
  • hungar
  • 操作

显示春菜