HBC25093听说你会KMP[USACO 2006 Dec B]The Eating Puzzle题解

回忆凄美了谁 算法基础篇 60 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
Bessie is on a diet where she can eat no more than C calories per day. Farmer John is teasing her by putting out B buckets of feed, each with some number of calories . Bessie has no self-control: once she starts on a feed bucket, she consumes all of it.Bessie is not so good at combinatorics. Determine the optimal combination of feed buckets that gives Bessie as many calories without exceeding the limit C.As an example, consider a limit of 40 calories and 6 buckets with 7, 13, 17, 19, 29, and 31 calories. Bessie could eat 7 + 31 = 38 calories but could eat even more by consuming three buckets: 7 + 13 + 19 = 39 calories. She can find no better combination.

Bessie is on a diet where she can eat no more than C (10 ≤ C ≤ 35,000) calories per day. Farmer John is teasing her by putting out B (1 ≤ B ≤ 21) buckets of feed, each with some (potentially non-unique) number of calories (range: 1..35,000). Bessie has no self-control: once she starts on a feed bucket, she consumes all of it. Bessie is not so good at combinatorics. Determine the optimal combination of feed buckets that gives Bessie as many calories without exceeding the limit C. As an example, consider a limit of 40 calories and 6 buckets with 7, 13, 17, 19, 29, and 31 calories. Bessie could eat 7 + 31 = 38 calories but could eat even more by consuming three buckets: 7 + 13 + 19 = 39 calories. She can find no better combination.

HBC25093听说你会KMP[USACO 2006 Dec B]The Eating Puzzle题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC25093听说你会KMP[USACO 2006 Dec B]The Eating Puzzle题解