当前位置:网站首页>分组背包
分组背包
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];
*/
边栏推荐
- leetcode hot 100(刷题篇9)(301/45/517/407/offer62/MST08.14/)
- Ga-rpn: recommended area network for guiding anchors
- Clickhouse learning (II) Clickhouse stand-alone installation
- Classic interview question: = = the difference between equals
- 深度学习(2):图片文字识别
- Virtual augmentation and reality Part 2 (I'm a Firebird)
- 搜索与回溯经典题型(八皇后)
- WQS binary learning notes
- Markdown concise grammar manual
- pnpm install出现:ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies
猜你喜欢

Clion+opencv+aruco+cmake configuration

数仓分层设计及数据同步问题,,220728,,,,

Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
![[opencv] - Operator (Sobel, canny, Laplacian) learning](/img/24/4e40408b61ec2c714b750b05a534c7.png)
[opencv] - Operator (Sobel, canny, Laplacian) learning

MySQL中的时间函数

【OpenCV】-算子(Sobel、Canny、Laplacian)学习

QT learning: use non TS files such as json/xml to realize multilingual internationalization

Application scheme of charging pile

Deep learning (1): prediction of bank customer loss

Data warehouse layered design and data synchronization,, 220728,,,,
随机推荐
Smart energy management system solution
Several ways of debugging support under oneos
AI application lesson 1: C language Alipay face brushing login
Component transfer participation lifecycle
7.2-function-overloading
Crawling JS encrypted data of playwright actual combat case
Product promotion channels and strategies, cosmetics brand promotion methods and steps
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
Time function in MySQL
PostgreSQL手动创建HikariDataSource解决报错Cannot commit when autoCommit is enabled
[opencv] - Operator (Sobel, canny, Laplacian) learning
Vs2019 compilation cryengine failure problem handling
Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
用户身份标识与账号体系实践
commonjs导入导出与ES6 Modules导入导出简单介绍及使用
深度学习(2):图片文字识别
Day15: the file contains the vulnerability range manual (self use file include range)
Inclination sensor accuracy calibration test
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
TCP - sliding window