当前位置:网站首页>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
边栏推荐
- Introduction to matlab
- L2-024 部落 (25 分)(并查集)
- 关于堆的判断 (25 分) 两种插入方式
- 计算神经网络推理时间的正确方法
- Automatic differentiation and higher order derivative in deep learning framework
- Mini - exercice MySQL (seulement pour les débutants, pas pour les non - débutants)
- K210 learning notes (II) serial communication between k210 and stm32
- dataBinding中使用include
- 错误: 找不到或无法加载主类
- GUI编程简介 swing
猜你喜欢
Strength comparison vulnerability of PHP based on hash algorithm
MySQL small exercise (only suitable for beginners, non beginners are not allowed to enter)
EmuElec 编译总结
Production practice elk
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Arbre de dépendance de l'emballage des ressources
Failed to download esp32 program, prompting timeout
Brief steps to build a website / application using flash and H5
Four pictures to understand some basic usage of Matplotlib
First principle mind map
随机推荐
Illegal character in scheme name at index 0:
Latex mathematical formula
LLVM之父Chris Lattner:编译器的黄金时代
LGB, XGB, cat, k-fold cross validation
Arbre de dépendance de l'emballage des ressources
L2-024 tribe (25 points) (and check the collection)
L2-022 rearrange linked list (25 points) (map + structure simulation)
Redis Desktop Manager for Mac
EmuElec 编译总结
Write down the post order traversal of the ~ binary tree
Harbor enterprise image management system
L2-023 graph coloring problem (25 points) (graph traversal)
BK3633 规格书
Multi view depth estimation by fusing single view depth probability with multi view geometry
OneFlow學習筆記:從Functor到OpExprInterpreter
bashdb下载安装
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
Open services in the bottom bar of idea
I don't understand time, timestamp and time zone. Look at this article
[Luke V0] verification environment 2 - Verification Environment components