Codeforces 148E. Porcelain
来源:互联网 发布:php开源微商城系统 编辑:程序博客网 时间:2024/05/15 02:06
预处理每个架子上打坏n个的最大毁坏值,就转化成经典的分组背包问题了.......
import java.util.*;public class Porcelain { static int n, m; static int[] s = new int[110]; static int[][] sum = new int[110][110]; static int[][] dem = new int[110][110]; static int[][] dp = new int[110][11000]; public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); for (int i = 1; i <= n; i++) { s[i] = in.nextInt(); for (int j = 1; j <= s[i]; j++) { int x = in.nextInt(); sum[i][j] = sum[i][j - 1] + x; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= s[i]; j++) { int t = 0; for (int left = 0; left <= j; left++) { int right = j - left; int temp = sum[i][left] + sum[i][s[i]] - sum[i][s[i] - right]; t = Math.max(t, temp); } dem[i][j] = t; } } for (int i = 1; i <= n; i++) { for (int j = m; j >= 0; j--) { for (int k = 0; k <= s[i] && k <= j; k++) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - k] + dem[i][k]); } } } System.out.println(dp[n][m]); }}
4 1
- Codeforces 148E(Porcelain)
- Codeforces 148E. Porcelain
- CodeForces 148E Porcelain
- codeforces-148E Porcelain
- CodeForces 148E – Porcelain
- codeforces 148E Porcelain (dp)
- codeforces-148E-Porcelain【DP】
- Codeforces 148 E Porcelain【dp】
- Codeforces 148 E Porcelain dp
- codeforces 148E Porcelain 多重背包
- Codeforces 148E Porcelain [预处理+dp背包]
- Codeforces 148E. Porcelain【多重背包】
- CodeForces 148E Porcelain dp+背包(水
- codeforces 148E Porcelain(DP, 分组背包)
- CodeForces 148E Porcelain(dp+背包)
- Codeforces 148E Porcelain (dp)
- Codeforces 148E Porcelain (预处理+多重背包)
- Codeforces Round #105 (Div. 2)--E. Porcelain 01背包
- HDU 3998 Sequence
- 出生在Agilent的孩子IEEE1588
- IAR安装调试的问题
- 面试-操作系统
- 创建处理文档的索引类: IndexProcessor
- Codeforces 148E. Porcelain
- cc2530寄存器按字母排序
- Linux内存管理之mmap详解
- SQOOP
- ISR中清中断标志的时机
- 笔记
- neural network and deep learning (1)
- jsp struts2 学习(二) ----- 响应
- Topographic ICA as a Model of Natural Image Statistics(作为自然图像统计模型的拓扑独立成分分析)