#include <iostream>
#include <cstring>
using namespace std;
const int maxn = ;
int s[maxn];//s[i]表示每行前i个数的和
int d[maxn];//d[i]表示每行取i个数时的最大价值
int f[];//限制数量为k个,往f中背,记录最大价值
int n,m,k;
int main()
{
cin >> n >> k;
for(int i = ; i <= n; ++i)
{
cin >> m;
for(int j = ; j <= m; ++j)
{
int x;
cin >> x;
s[j] = x + s[j-];
}
memset(d,,sizeof d);
for(int j = ; j <= m; ++j)
for(int l = ; l <= j; ++l)
if(s[l]+s[m]-s[m+l-j] > d[j])
d[j] = s[l] + s[m] -s[m+l-j];
for(int j = k; j > ; --j)
for(int l = ; l <= min(j,m); ++l)
if(f[j-l]+d[l] > f[j])
f[j] = f[j-l] + d[l];
}
cout << f[k] << endl;
return ;
}

codeforces148----E. Porcelain的更多相关文章

  1. Codeforces Round #105 (Div. 2) E. Porcelain —— DP(背包问题)

    题目链接:http://codeforces.com/problemset/problem/148/E E. Porcelain time limit per test 1 second memory ...

  2. [CF148E] Porcelain (分组背包)

    题目链接:http://codeforces.com/problemset/problem/148/E 题目大意:有n组数据,每次可以从任意一组的两端取出1个数,问你取m个数最大能组成多少? 思路:先 ...

  3. 设计模式(三):“花瓶+鲜花”中的装饰者模式(Decorator Pattern)

    在前两篇博客中详细的介绍了"策略模式"和“观察者模式”,今天我们就通过花瓶与鲜花的例子来类比一下“装饰模式”(Decorator Pattern).在“装饰模式”中很好的提现了开放 ...

  4. git 修改最后一次提交的用户名 或者 commit的内容

    修改git最后一次提交的命令 $ git commit --amend 修改git最后一次提交用户名的相关命令 git config user.name 'wangz' git config user ...

  5. Git 进阶指南

    转自: https://github.com/kaiye/kaiye.github.com/issues/7 在掌握了基础的 Git 使用 之后,可能会遇到一些问题.以下是猫哥筛选总结的部分常见问题, ...

  6. git subtree 使用

    这个是备忘录.原网页(https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec , http://cncc.bingj.co ...

  7. git push --help

    git-push(1) Manual Page NAME git-push - Update remote refs along with associated objects SYNOPSIS gi ...

  8. Git for Windows v2.11.0 Release Notes

    homepage faq contribute bugs questions Git for Windows v2.11.0 Release Notes Latest update: December ...

  9. github提交失败并报错java.io.IOException: Authentication failed:

    一.概述 我最近在写一个android的项目. 软件:android studio.Android studio VCS integration(插件) Android studio VCS inte ...

随机推荐

  1. 【层次聚类】python scipy实现

    层次聚类 原理 有一个讲得很清楚的博客:博客地址 主要用于:没有groundtruth,且不知道要分几类的情况 用scipy模块实现聚类 参考函数说明: pdist squareform linkag ...

  2. Nginx详解十三:Nginx场景实践篇之防盗链

    防盗链: 目的:防止资源被盗用 防盗链设置思路 首要方式:区别哪些请求是非正常的用户请求 基于http_refer防盗链配置模块(判断refer(上一步的链接)信息是否为允许访问的网站) 配置语法:v ...

  3. linux把程序做成系统服务并自启动

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 一.chkconfig 的使用语法1.c ...

  4. Appium Demo

    import unittestimport timefrom appium import webdriverfrom public import configimport os #类继承unittes ...

  5. 解决OS睡眠功能中,移动鼠标就会唤醒

    设备管理器,在相应项目上右键属性.

  6. [转] 对express中next函数的一些理解

    最近公司在使用node做前后端分离,采用的web框架是express,所以对express框架进行了深入的了解,前段时间写了篇关于express路由的文章,但是在那篇文章中貌似少了一个很重要的内容,就 ...

  7. 【BZOJ4998】星球联盟

    题解: 应该还是比较水的 首先很容易发现的就是两个点一旦联通他们就永远联通了 所以联通之后我们就把他们之间缩成一个点

  8. Summary of continuous function spaces

    In general differential calculus, we have learned the definitions of function continuity, such as fu ...

  9. x86 版的 Arduino Intel Galileo 开发板的体验、分析和应用

    1.前言 在今年(2013)罗马举办的首届欧洲 Make Faire 上,Intel 向对外发布了采用 x86 构架的 Arduino 开发板:Intel Galileo.这无疑是一个开源硬件领域的重 ...

  10. ssh连接时提示THE AUTHENTICITY OF HOST XX CAN’T BE ESTABLISHED

    ssh链接云主机: ssh root@123.59.xx.xx 报错:THE AUTHENTICITY OF HOST XX CAN’T BE ESTABLISHED 解决办法: ssh -o Str ...