SDUT 2408 Pick apples

一开始以为是完全背包问题,但是背包的体积V太大,直接背包果断不过。 

  正解应该是 大范围贪心,小范围背包。

  直接谈心不能保证充分利用背包的体积,从而不能保证找到最优解。

  但是背包找到的最优解也肯定是尽可能将性价比高的物品放进去。

  这样答题思路就出来了,先分出一部分空间 V1 来用来贪心,剩余部分 V2 = V - V1用来背包,贪心即选择性价比最高的物品放进去。

  如果贪心后 V1 有剩余的空间 , 设剩余空间为V3,则应将V3回收用来背包,即 V2 += V3。

  这样得出的结构就是正确答案了。

  但是这里还牵扯到一个问题,那就是V1和V2的划分问题。

  这里有两种方法,一种就是直接分出较大的一部分空间来用来背包,显然此部分要在时间和空间上都能承受。

  还有一种就是找给出的这三个体积的最小公倍数,至于为什么这样能行,我也不知道了,坐等大神来证明 o(∩_∩)o

时间: 2025-01-31 09:04:18

SDUT 2408 Pick apples的相关文章

[2012山东ACM省赛] Pick apples (贪心,完全背包,枚举)

Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she

[2012山东ACM省赛] Pick apples (贪心,全然背包,枚举)

Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描写叙述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because s

Pick apples 第三届acm省赛

Description Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each ki

Pick apples(完全背包+贪心)

Description Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each ki

sdut2408 pick apples (贪心+背包)山东省第三届ACM省赛

本文出自:http://blog.csdn.net/svitter/ 题意:三种苹果,每种都有对应的Size,Value,给你一个背包空间,求最大的价值. 本题目的关键就在于非常大的背包空间 依据indicates the size (1 <= S<= 100) 我们可以考虑在1000000(100^3)之外的空间放性价比最高的苹果.为什么时100^3? 要知道背包如果正好填满,而填满空间相应价值的苹果大于不填满的价值的苹果,那么就选择能填满空间而使价值最大的苹果,而非性价比最高的苹果--性价

HDU 5303 Delicious Apples(贪心 + 背包 2015多校啊)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5303 Problem Description There are n apple trees planted along a cyclic road, which is L metres long. Your storehouse is built at position 0 on that cyclic road. The ith tree is planted at position xi,

HDU 5303 Delicious Apples (贪心 枚举 好题)

Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 199    Accepted Submission(s): 54 Problem Description There are n apple trees planted along a cyclic road, which is L metres l

2015 Multi-University Training Contest 2 hdu 5303 Delicious Apples

Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1057    Accepted Submission(s): 354 Problem Description There are n apple trees planted along a cyclic road, which is L metres

HDU 5303 Delicious Apples (2015多校第二场 贪心 + 枚举)

Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 321    Accepted Submission(s): 95 Problem Description There are  apple trees planted along a cyclic road, which is  metres lon