当前位置:网站首页>分组背包
分组背包
2022-07-29 08:32:00 【蒟】
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int dp[N];
int v[N][N], w[N][N], s[N];
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> s[i];
for (int j = 1; j <= s[i]; j++) {
cin >> v[i][j] >> w[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=m;j>=0;j--)
{
for(int k=1;k<=s[i];k++)
{
if(j>=v[i][k])
{
dp[j]=max(dp[j],dp[j-v[i][k]]+w[i][k]);
}
}
}
}
cout<<dp[m];
return 0;
}
/*
其动态转移方程为dp[i][j]=max(dp[i-1][j-v[i][k]]+w[i][k];
*/
边栏推荐
- Cs5340 domestic alternative dp5340 multi bit audio a/d converter
- 数仓分层设计及数据同步问题,,220728,,,,
- Unity shader learning (VI) achieving radar scanning effect
- Centos7/8 command line installation Oracle11g
- Day6: use PHP to write file upload page
- Day5: PHP simple syntax and usage
- 谷歌浏览器免跨域配置
- Personal study notes
- Play Parkour with threejs Technology
- 【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
猜你喜欢
6.3 references
MySQL statement mind map
Centos7/8 command line installation Oracle11g
Chrony 时间同步
C language watch second kill assist repeatedly
Intel将逐步结束Optane存储业务 未来不再开发新产品
Day15: the file contains the vulnerability range manual (self use file include range)
Noise monitoring and sensing system
Simulation of four way responder based on 51 single chip microcomputer
Analysis of zorder sampling partition process in Hudi - "deepnova developer community"
随机推荐
Leetcode Hot 100 (brush question 9) (301/45/517/407/offer62/mst08.14/)
Compatible with cc1101/cmt2300-dp4301 sub-1g wireless transceiver chip
Noise monitoring and sensing system
数仓分层设计及数据同步问题,,220728,,,,
Hal learning notes - Advanced timer of 7 timer
MySQL statement mind map
Search and recall classic questions (eight queens)
WQS binary learning notes
Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
Virtual augmentation and reality Part 2 (I'm a Firebird)
Stm8s003 domestic substitute for dp32g003 32-bit microcontroller chip
Arfoundation Getting Started tutorial 7-url dynamically loading image tracking Library
Ar virtual augmentation and reality
Stm32ff030 replaces domestic MCU dp32g030
Basic shell operations (Part 2)
Osgsimplegl3 combined with renderdoc tool
Product promotion channels and strategies, cosmetics brand promotion methods and steps
What if official account does not support markdown format file preparation?
分段分页以及段页结合
ROS common instructions