
dp---背包问题
长沙大学ccsu_deer
这个作者很懒,什么都没留下…
展开
-
背包问题--01背包 (Bitset的优化) 多重背包 (二进制优化)
01背包问题:题目链接题意:n个物品一个m容量的背包,n个物品有need[i]的体积消耗,以及权值value[i] ,问m容量装n个物品能得到的最大权值是多少。做法:01背包介绍:博客代码:#include<bits/stdc++.h>using namespace std;typedef long long ll;inline ll read(){ ll x=0,w=1; char c=getchar(); while(c<'0'||c>'9'.原创 2020-06-21 11:58:08 · 4940 阅读 · 0 评论 -
百度AI小课堂-上升子序列(中等)(二分图染色+分组背包)
百度AI小课堂-上升子序列(中等)题目链接:https://nanti.jisuanke.com/t/39266问答问题反馈题目描述给一个长度为nn的数组aa。试将其划分为两个严格上升子序列,并使其长度差最小。对于每组数据输出一行一个整数,表示两个子序列的最小长度差。若不存在划分方案则输出−1。271 4 2 5 6 3 755...原创 2019-06-26 15:20:54 · 437 阅读 · 0 评论 -
E. Optimal Slots(01背包记录路径)
time limit per test2.0 smemory limit per test256 MBinputstandard inputoutputstandard outputThe main hall of your residency is open for use by the local community and public. Since i...原创 2019-06-23 20:10:09 · 866 阅读 · 2 评论 -
Miku and Generals(2019西安邀请赛D题 染色加分组背包)
Miku is matchless in the world!” As everyone knows, Nakano Miku is interested in Japanese generals, so Fuutaro always plays a kind of card game about generals with her. In this game, the players pick ...原创 2019-06-17 17:29:53 · 505 阅读 · 0 评论 -
G - 完全背包 poj2063
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...原创 2019-05-30 10:14:52 · 327 阅读 · 0 评论 -
hdu3033 I love sneakers! (另类完分组背包 每种至少买一个)
After months of hard working, Iserlohn finally wins awesome amount of scholarship. As a great zealot of sneakers, he decides to spend all his money on them in a sneaker store.There are several b...原创 2019-05-30 08:55:14 · 373 阅读 · 0 评论 -
D - 分组背包 基础hdu1712(每种至多选一个)
ACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to arrange the M days for ...原创 2019-05-28 08:50:47 · 341 阅读 · 0 评论 -
E-HDU - 2955(01背包 加概率)
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative...原创 2019-05-24 19:56:11 · 392 阅读 · 0 评论 -
K-hdu2639 01背包的K值问题
The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't matter,I will give you a...原创 2019-05-24 19:52:56 · 363 阅读 · 0 评论 -
Chat(分组背包)
链接:https://ac.nowcoder.com/acm/contest/893/H来源:牛客网题目描述在Casya生活的世界里,一天由m个小时组成。最近Casya的女神终于答应在接下来的n天中与Casya聊天,Casya非常激动。在这n天中的每一天的每一个小时中女神可能会在线或者不在线,某个小时如果女神如果在线且Casya在线的话他们就会开心的聊一个小时;反之如果女神在...原创 2019-05-05 19:29:02 · 359 阅读 · 0 评论 -
背包问题3--多重背包
该问题与“完全背包”相比,在每个物品的选取次数上给出了限定,即选取次数k不能无限的增大,其方程和“完全背包”的极度相似,只是k的限定条件发生了变化。 #include<cdtdio> using namespace std; int dp[1005]; int weight[1005],value[1005],num[1005]; ...原创 2019-05-05 15:31:02 · 550 阅读 · 0 评论 -
背包问题2--完全背包
01背包即无重复选取,每个物品仅放一次。多完全背包就不一样了。它可以重复选取,由01背包演化而来。下面仅贴模板代码/*完全背包问题的特点是,每种物品可以无限制的重复使用,可以选择放或不放。完全背包问题描述:有N物品和一个容量为V的背包。第i件物品的重量是wei[i],价值是val[i]。*/ #include<cstdio>#include<cstring...原创 2019-05-05 15:29:26 · 866 阅读 · 0 评论 -
背包问题1--简单01背包
#1038 : 01背包时间限制:20000ms单点时限:1000ms内存限制:256MB描述且说上一周的故事里,小Hi和小Ho费劲心思终于拿到了茫茫多的奖券!而现在,终于到了小Ho领取奖励的时刻了!小Ho现在手上有M张奖券,而奖品区有N件奖品,分别标号为1到N,其中第i件奖品需要need(i)张奖券进行兑换,同时也只能兑换一次,为了使得辛苦得到的奖券不白白浪费,小Ho给每...原创 2018-12-03 17:21:08 · 428 阅读 · 0 评论