当前位置:网站首页>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
边栏推荐
- Notes d'apprentissage oneflow: de functor à opexprinterpreter
- web页面如何渲染
- To remember the composition ~ the pre order traversal of binary tree
- Single chip microcomputer nixie tube stopwatch
- Technological innovation in government affairs in the construction of Digital Government
- bashdb下载安装
- [boutique] using dynamic agent to realize unified transaction management II
- MySQL小練習(僅適合初學者,非初學者勿進)
- Illegal character in scheme name at index 0:
- Judgment on heap (25 points) two insertion methods
猜你喜欢

MATLAB入门资料

爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法

Valgrind et kcachegrind utilisent l'analyse d'exécution

企业微信应用授权/静默登录

Failed to download esp32 program, prompting timeout

EmuElec 编译总结

PCTP考试经验分享

Introduction to GUI programming swing

Share the office and improve the settled experience

PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
随机推荐
MySQL查询两张表属性值非重复的数据
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
搞不懂时间、时间戳、时区,快来看这篇
Illegal character in scheme name at index 0:
Go语言自学系列 | golang结构体作为函数参数
Taxable income
Chris LATTNER, father of llvm: the golden age of compilers
Download and install bashdb
Wechat: get the owner of a single tag
[58] length of the last word [leetcode]
Basic usage of synchronized locks
Find the sum of simple types of matrices
玩转二叉树 (25 分)
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
Is Zhongyan futures safe and reliable?
2021 Li Hongyi's adaptive learning rate of machine learning
idea打包 jar文件
I don't understand time, timestamp and time zone. Look at this article
[original] use system Text. JSON formats the JSON string
Correct method of calculating inference time of neural network