当前位置:网站首页>[Best training DAY16] KC's Can [Dynamic programming]
[Best training DAY16] KC's Can [Dynamic programming]
2022-07-30 00:15:00 【六世——MOESR】

思路:
First converted into limited knapsack problem,But the card often card in the past
c o d e code code
#include<iostream>
#include<cstdio>
#define re register
using namespace std;
int n, m;
int a[110][110], sum[110][110], p[110][110], f[110][10001], g[10001], s[10001];
int main() {
scanf("%d%d", &n, &m);
for(re int i = 1; i <= n; ++ i) {
scanf("%d", &a[i][0]);
for(re int j = 1; j <= a[i][0]; ++ j)
scanf("%d", &a[i][j]), sum[i][j] = a[i][j] + sum[i][j - 1];
for(re int j = 0; j <= a[i][0]; ++ j) {
p[i][j] = 1e9;
re int q = a[i][0] - j;
for(re int k = 1; k + q - 1 <= a[i][0]; ++ k) {
p[i][j] = min(p[i][j], sum[i][k + q - 1] - sum[i][k - 1]);
}
p[i][j] = sum[i][a[i][0]] - p[i][j];
}
}
for(re int i = 1; i <= n; ++ i) {
for(re int j = 0; j <= a[i][0]; ++ j) {
for(re int k = m; k >= j; -- k) {
if(g[k - j] + p[i][j] > f[j][k]) f[j][k] = g[k - j] + p[i][j];
if(f[j][k] > s[k]) s[k] = f[j][k];
}
}
for(re int k = m; k >= 0; -- k)
g[k] = s[k];
}
printf("%d", g[m]);
return 0;
}
边栏推荐
- Worthington Optimized Technology: Cell Quantification
- Music theory & guitar skills
- ZLMediaKit源码分析 - WebRtc连接迁移
- Decision tree principle and code implementation
- rk-boot framework combat (1)
- Weekly recommended short video: What is R&D efficiency?It can achieve anti "involution"?
- 谷歌浏览器(google)设置翻译中文,翻译选项不生效或没有弹出翻译选项
- QTableWidget使用示例
- 随便记记第二周
- 图像的IO操作
猜你喜欢

定时器学习
![[Cloud native Kubernetes] Build a Kubernetes cluster in binary (middle) - deploy node nodes](/img/07/7f19751f4eadf9fd5612f56d1936d1.png)
[Cloud native Kubernetes] Build a Kubernetes cluster in binary (middle) - deploy node nodes

Reading notes. This is the psychology: see through the essence of the pseudo psychology (version 10)"

微信开发者工具设置制表符大小为2

WeChat developer tools set the tab size to 2

新媒体运营必备的4个热点查询网

读书笔记:《这才是心理学:看穿伪心理学的本质(第10版)》

Worthington弹性蛋白酶&透明质酸酶简介

How to design and implement report collaboration system for instruction set data products——Development practice of industrial collaborative manufacturing project based on instruction set IoT operating

中文语义匹配
随机推荐
Mysql internal and external connections
WeChat developer tools set the tab size to 2
First Normal Form, Second Normal Form, Third Normal Form
旋转数组的最小数字
ZLMediaKit源码分析 - NotifyCenter
中文语义匹配
Comprehensive Practice - Three-Mison Chess Mini Game
外包干了五年,废了...
MySQL 用 BETWEEN AND 日期查询包含范围边界
Filebeat如何保证在日志文件被切割(或滚动rolling)时依然正确读取文件
KDE Frameworks 5.20.0:Plasma迎来诸多改进
what is a .pro file in qt
try_catch捕获异常
BEVDetNet: Bird's Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi
Decision tree principle and code implementation
工厂模式
Laravel 预防 SQL 注入
直播平台搭建,设置状态栏颜色
经典论文-SqueezeNet论文及实践
EA&UML日拱一卒-状态图::重画按钮状态图