题目:
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.
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.
输入:
* Line 1: Two space-separated integers: C and N
* Lines 2..N+1: Line i+1 contains a single integer: W_i
输出:
* Line 1: A single integer that is the weight of the heaviest group of cows that can go to the movies
样例输入:
259 5 81 58 42 33 61
样例输出:
242
注释:
81+58+42+61 = 242;
this is the best possible sum
Source: USACO Open 2008 Bronze
翻译:
描述:
农民John正带着一些他的奶牛去电影院,然而他的卡车有容量限制,C(100 <= C <= 5000) 千克,在重量不要超过限制C的情况下,
他想尽可能多的带走奶牛。
给出N (1 <= N <= 16)头奶牛和它们代表的重量W_i,决定FJ可带去电影院的最重的一群奶牛的重量。
输入:
第1行:两个空格分隔开的整数C和N。
第2...N+1行:N+1行包含一个单独的整数 :W_i
输出:
*第一行:一个单独的整数,能带去电影院的最重的一群母牛的重量。