当前位置:网站首页>[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;
}
边栏推荐
- 【分层强化学习】survey
- The go language (functions, closures, defer, panic/recover, recursion, structure, json serialization and deserialization)
- Worthington's tried and tested cell isolation system protocols
- How do we-media people create explosive articles?These 3 types of articles are most likely to explode
- KDE Frameworks 5.20.0: Plasma welcomes many improvements
- try_catch捕获异常
- BEVDetNet: Bird's Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi
- Go language serialization and deserialization and how to change the uppercase of the json key value to lowercase if the json after serialization is empty
- 单片机开发之拓展并行I/O口
- Worthington解离酶:胰蛋白酶及常见问题
猜你喜欢

更换可执行文件glibc版本的某一次挣扎

“灯塔工厂”的中国路径:智造从点到面铺开

关于MySQL索引的一些个人理解(部分参考MySQL45讲)

Since the media how to write a short video title?Three hot style title, let your video gain more traffic

决策树原理及代码实现

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

At the age of 29, I was fired from a functional test. Can't find a job after 2 months of interviews?

KDE Frameworks 5.20.0: Plasma welcomes many improvements

Worthington's tried and tested cell isolation system protocols

18 Lectures on Disassembly of Multi-merchant Mall System Functions
随机推荐
rk-boot framework combat (1)
工厂模式
vmtouch——Linux下的文件缓存管理神器
Docker install MySQL8.0
Adaptive feature fusion pyramid network for multi-classes agriculturalpest detection
QTableWidget使用示例
利用热点事件来创作软文的3大技巧?自媒体人必看
【集训DAY18】Welcome J and Z 【动态规划】
Decision tree principle and code implementation
【经验】经验总结-经验教训
EA&UML日拱一卒-多任务编程超入门-(8)多任务安全的数据类
重写并自定义依赖的原生的Bean方法
Laravel 预防 SQL 注入
Low dropout linear regulator MPQ2013A-AEC1 brand MPS domestic replacement
Worthington优化技术:细胞定量
窗口函数笔记
Mysql internal and external connections
He cell separation technology 丨 basic primary cell separation methods and materials
【Incubator DAY18】Interesting exchange【Simulation】【Math】
News text classification