No.11 Going to the Movies

原文:

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

译文:

去上电影

 10000ms  1000K

描述:

农民John正在准备他的奶牛上电影!但是他的拖拉机的重量限制为C(100 <= C <=5000)千克,John想在不超过限重的情况下尽可能多的运奶牛使得重质量最大。

给出N头奶牛以及她们各自的重量,你的任务是找到John所能带的奶牛最大总质量。

输入:

第一行包含两个整数C和N用一个,空格隔开

接下来N行,每行包含一个整数用来表示每只奶牛的重量

输出:

John能带的奶牛最大总重量

样例输入:

259 5
81
58
42
33
61

样例输出:

242

注释:

81+58+42+61 = 242;
这是最佳的组合情况

Source: USACO Open 2008 Bronze

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值