https://acs.jxnu.edu.cn/problem/NOIOPJCH02072393
Going to the Movies
10000ms 1000K
描述:
Farmer John is taking some of his cows to the movies! While his truck has a limited capacity of C (100 <= C <= 5000) kilograms, he wants to take the cows that, in aggregate, weigh as much as possible without exceeding the limit C.
(农场主John 打算带他自己的牛群去拍电影。但是他的卡车有最大承载重量Ckg,他打算尽可能多地去带牛去并且不超过这个最大限度C.)
Given N (1 <= N <= 16) cows and their respective weights W_i, determine the weight of the heaviest group of cows that FJ can take to the movies.
(给定N头牛,和他们各自的重量W-i,判断能带去拍电影的最大的牛的重量。 )
输入:
* Line 1: Two space-separated integers: C and N
* Lines 2..N+1: Line i+1 contains a single integer: W_i
(第一行:用空格分隔的两个整数:C和N。)
(第二行…N+1:有一个单一 的整数:W-i)
输出:
* Line 1: A single integer that is the weight of the heaviest group of cows that can go to the movies
(输出一行:能带去拍电影的牛群最大质量。)