
ACM_背包问题
文章平均质量分 77
深海沧澜夜未央
这个作者很懒,什么都没留下…
展开
-
完全背包 (模板题目)
蒜头君去超市购物,他有一只容量为 V 的购物袋,同时他想买 n 种物品,已知每种物品的体积 vi 和重要度 pi。蒜头君想知道,怎么挑选物品放入购物袋中,可以使得买到的物品重要度之和最大,且物品体积和不超过购物袋的容量。注意超市中每种物品的数量无限多。输入格式第一行输入两个整数 n,v接下来输入 n 行,每行输入两个整数 v_i ≤10,000),分别表示第 ii 种物品的体积和重要原创 2018-01-30 20:14:51 · 711 阅读 · 0 评论 -
AtCoder Grand Contest 020 C - Median Sum (背包问题+bitset )
Time limit : 2sec / Memory limit : 512MBScore : 700 pointsProblem StatementYou are given N integers A1, A2, ..., AN.Consider the sums of all non-empty subsequences of A. There are原创 2018-01-19 20:05:18 · 548 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第二场) B TaoTao要吃鸡 (0 1背包 特殊处理一个物品)
Taotao的电脑带不动绝地求生,所以taotao只能去玩pc版的荒野行动了,和绝地求生一样,游戏人物本身可以携带一定重量m的物品,装备背包之后可以多携带h(h为0代表没有装备背包)重量的东西。玩了几天taotao发现了一个BUG,当装备背包之后,如果可携带重量没有满,就可以拿一个任意重的东西。(解释看样例)有一天taotao空降到了一个奇怪的岛上,岛上有n件装备,每个装备都有原创 2018-01-30 12:09:49 · 396 阅读 · 0 评论 -
背包总结
01背包问题:给定一组物品,每种物品都有自己的重量/体积 (一般我用数组w[i]表示) 和价值(数组v[i]表示),现有一个背包(m),若取若干物品,使得总价值最大(dp[n][m])所以一般一个题目只是要有一个 价值数组v[] 重量数组 w[] 还有背包m 计算 数组dp[][]dp[i][j] 代表的是前i个物品在总重量不超过j的时候的最大价值。模板: http://blog.csd...原创 2018-01-24 17:07:58 · 215 阅读 · 0 评论 -
POJ - 3260 The Fewest Coins ( 多重背包 min 价值为1)
Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coin原创 2018-02-02 10:53:38 · 277 阅读 · 0 评论 -
HDU 2844 Coins 多重背包 (重量和价值相同)
Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a原创 2018-02-02 12:11:28 · 425 阅读 · 0 评论 -
POJ 1276 Cash Machine ( 多重背包模板题目 )
DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denomin原创 2018-01-31 23:15:41 · 279 阅读 · 0 评论 -
POJ 2392 Space Elevator ( 多重背包 背包限制不同 + 贪心 )
DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which原创 2018-02-01 00:11:10 · 444 阅读 · 0 评论 -
POJ - 2184 Cow Exhibition (01背包 中 负数的处理)
"Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to the public that they are both smart and fun. In order to do this, ...原创 2018-01-24 16:23:27 · 623 阅读 · 0 评论 -
HDU - 3466 Proud Merchants (01背包的变形 + 贪心)
Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud even if their n原创 2018-01-24 16:35:39 · 298 阅读 · 0 评论 -
POJ - 3624 Charm Bracelet (01背包 模板 )
Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the原创 2018-01-24 16:13:52 · 248 阅读 · 0 评论 -
POJ 3181 Dollar Dayz (完全背包 + 大数分离输出)
Farmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer John has exactly原创 2018-01-30 21:30:59 · 315 阅读 · 0 评论 -
POJ 2063 Investment (多轮完全背包 )
John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only in原创 2018-01-30 21:05:50 · 219 阅读 · 0 评论 -
HDU 1248 寒冰王座 (完全背包 水题)
Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说完他掏出那张N元的大钞递给地精商原创 2018-01-30 20:24:48 · 321 阅读 · 0 评论 -
01背包的多种另类解法 第十四届华中科技大学程序设计竞赛决赛同步赛 F Beautiful Land 01背包的多种另类解法
It’s universally acknowledged that there’re innumerable trees in the campus of HUST. Now HUST got a big land whose capacity is C to plant trees. We have n trees which could be plant in it. Each of the...原创 2018-05-07 20:23:34 · 299 阅读 · 0 评论