当前位置:网站首页>Group Backpack
Group Backpack
2022-04-23 09:03:00 【2020100XWH】
All items are divided into k Group , Intra group mutual exclusion
Pair up 01 knapsack , Which of the last one-dimensional enumeration group
#include<bits/stdc++.h>
using namespace std;
int dp[1005];
struct one{
int m,w;
};
vector <one> v[1005];
int main()
{
int n,m;
cin>>m>>n;
int a,b,c;
for(int i=1;i<=n;++i)
{
cin>>a>>b>>c;
v[c].push_back((one){a,b});
}
for(int i=1;i<=1000;++i)
{
if(v[i].size())
{
for(int j=m;j>=0;--j)
{
for(int k=0;k<v[i].size();++k)
{
if(j>=v[i][k].m)
dp[j]=max(dp[j],dp[j-v[i][k].m]+v[i][k].w);
}
}
}
}
cout<<dp[m];
return 0;
}
版权声明
本文为[2020100XWH]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230721150210.html
边栏推荐
- Go语言自学系列 | golang结构体作为函数参数
- Learn SQL injection in sqli liabs (Level 11 ~ level 20)
- Pctp test experience sharing
- MYCAT configuration
- Automatic differentiation and higher order derivative in deep learning framework
- LaTeX论文排版操作
- Notes on xctf questions
- Judgment on heap (25 points) two insertion methods
- LeetCode396. Rotate array
- 搜索树判断 (25 分)
猜你喜欢
资源打包关系依赖树
调包求得每个样本的k个邻居
Summary of solid problems
What is augmented reality technology? Where can it be used?
MySQL查询两张表属性值非重复的数据
npm ERR! network
搞不懂时间、时间戳、时区,快来看这篇
PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
Mini - exercice MySQL (seulement pour les débutants, pas pour les non - débutants)
Automatic differentiation and higher order derivative in deep learning framework
随机推荐
How does kubernetes use harbor to pull private images
Harbor enterprise image management system
The most concerned occupations after 00: civil servants ranked second. What was the first?
ONEFLOW learning notes: from functor to opexprinter
What is augmented reality technology? Where can it be used?
OneFlow學習筆記:從Functor到OpExprInterpreter
LeetCode396. Rotate array
Single chip microcomputer nixie tube stopwatch
还原二叉树 (25 分)
Illegal character in scheme name at index 0:
MATLAB入门资料
Data visualization: use Excel to make radar chart
Consensus Token:web3. 0 super entrance of ecological flow
Use include in databinding
完全二叉搜索树 (30 分)
深度学习框架中的自动微分及高阶导数
bashdb下载安装
Chris LATTNER, father of llvm: the golden age of compilers
Latex mathematical formula
[Luke V0] verification environment 2 - Verification Environment components