随笔分类 -  区间DP

1

HDU 2746 ——Max Sum Plus Plus Plus 【dfs+带备忘 或 DP】
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1244 Problem Description 给定一个由n个正整数组成的整数序列a1 a2 a3 ... an求按先后次序在其中取m段长度分别为l1、l2、l3...lm的不交叠的连续整数的和的最大值。 I 阅读全文

posted @ 2016-04-05 21:23 SuperChan 阅读(155) 评论(0) 推荐(0)

NYOJ 742 —— 最大m段和 【区间DP】
摘要:经典区间DP:最大m段和 “最大连续和问题”是最大m段和问题的一个特例,其实是当m=1的一种特殊情况。 OJ题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=742 参考: http://blog.csdn.net/liufeng_king/ar 阅读全文

posted @ 2016-04-05 15:53 SuperChan 阅读(165) 评论(0) 推荐(0)

NYOJ 746 - 正整数n划分为m段,求m段的最大乘积 【区间DP】
摘要:整数划分(四) 时间限制:1000 ms | 内存限制:65535 KB 整数划分(四) 时间限制:1000 ms | 内存限制:65535 KB 给出两个整数 n , m ,要求在 n 中加入m - 1 个乘号,将n分成m段,求出这m段的最大乘积 阅读全文

posted @ 2016-04-01 17:10 SuperChan 阅读(585) 评论(0) 推荐(1)

最长上升子序列 LIS
摘要:题目: http://acm.nyist.net/JudgeOnline/problem.php?pid=17 http://poj.org/problem?id=2533 两道题几乎一样,只不过对于输入输出的要求有所不同罢了。 LIS有两种方法: 一、第一种方法 · 时间复杂度为O(n^2): 状 阅读全文

posted @ 2016-03-31 23:19 SuperChan 阅读(232) 评论(0) 推荐(0)

POJ 1141 —— Brackets Sequence
摘要:题目:http://poj.org/problem?id=1141 区间DP + 构造出DP的解 这里有两种思路都是对的: 第一种(推荐):dp[i][j] := 区间i~j最少需要加多少字符使得它符合括号匹配,然后构造出一个DP的解就好了 第二种:dp[i][j] := 区间i~j符合括号匹配的最 阅读全文

posted @ 2016-03-31 15:40 SuperChan 阅读(177) 评论(0) 推荐(0)

最长公共子序列 LCS
摘要:题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=36 介绍一下定义先~ 子序列:一个序列的子序列,就是该序列删掉若干个(0~len-1)元素后的序列 公共子序列:一个序列c如果既是序列a删去若干元素后的结果,又是序列b删去若干元素后的结果,则: 阅读全文

posted @ 2016-03-31 13:54 SuperChan 阅读(382) 评论(0) 推荐(0)

POJ 3280 —— Cheapest Palindrome
摘要:题目:http://poj.org/problem?id=3280 经典的区间DP 阅读全文

posted @ 2016-03-30 22:52 SuperChan 阅读(136) 评论(0) 推荐(0)

POJ 3661 —— Running
摘要:题目:http://poj.org/problem?id=3661 这题要注意看清题意:一旦开始休息就要一直休息到疲劳值为0! 阅读全文

posted @ 2016-03-30 22:01 SuperChan 阅读(159) 评论(0) 推荐(0)

UVA - 10003 —— Cutting Sticks
摘要:题目:Cutting Sticks 很基础的一道区间DP :) 阅读全文

posted @ 2016-03-29 22:39 SuperChan 阅读(136) 评论(0) 推荐(0)

UVA - 10688 —— The Poor Giant
摘要:题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=36406 题目举的那个例子有些错误。。一看就能发现并且修正的:) 这道题算是最简单的区间DP问题之一了吧~以至于我很顺畅地就写出了转移方程,算是这几天训练区间DP的结果吧: 阅读全文

posted @ 2016-03-29 21:57 SuperChan 阅读(220) 评论(0) 推荐(0)

HDU 2746 ——String painter
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=2476 这道题,大多数博客都是一种解法:就是先得到无颜色的字符串涂色为所需字符串的最小次数(1),然后基于此去找当原先的字符串并不是无颜色的而是有固定颜色时的最小值(2)。怎样找呢?因为字符串原先已有颜色, 阅读全文

posted @ 2016-03-29 14:27 SuperChan 阅读(229) 评论(0) 推荐(0)

sdut 1309 —— 不老的传说问题
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1309 状态:dp[i][j] := 区间i~j都是无色时的最小涂色次数 转移:dp[i][j] = min(dp[i+1][j]+1 (单独涂色), 阅读全文

posted @ 2016-03-29 01:05 SuperChan 阅读(206) 评论(0) 推荐(0)

HDU 4283 —— You Are the One
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=4283 阅读全文

posted @ 2016-03-28 22:04 SuperChan 阅读(140) 评论(0) 推荐(0)

ZOJ - 3469 —— Food Delivery
摘要:题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3469 阅读全文

posted @ 2016-03-28 14:30 SuperChan 阅读(322) 评论(0) 推荐(0)

POJ 1651 —— Multiplication Puzzle
摘要:题目:http://poj.org/problem?id=1651 阅读全文

posted @ 2016-03-28 11:18 SuperChan 阅读(146) 评论(0) 推荐(0)

Light oj 1422 - Halloween Costumes
摘要:题目:http://lightoj.com/volume_showproblem.php?problem=1422 阅读全文

posted @ 2016-03-28 00:38 SuperChan 阅读(159) 评论(0) 推荐(0)

POJ 2955 —— Brackets
摘要:题目:http://poj.org/problem?id=2955 状态定义:dp[i][j] := 区间为i~j时的最大长度 方法1(推荐): dp[i][j] = min(dp[i+1][j],dp[i+1][k-1]+dp[k+1][j]+2)(i<=k<=j&&i和k是一对括号) 方法2: 阅读全文

posted @ 2016-03-27 22:42 SuperChan 阅读(159) 评论(0) 推荐(0)

数组删数,求最大得分
摘要:Description Time Limit: 1sec Memory Limit:256MB The teachers of SMIE are all playing games. XM also want to play so he invents a game. The game is als 阅读全文

posted @ 2016-03-26 22:11 SuperChan 阅读(329) 评论(0) 推荐(0)

ZOJ - 3537 —— Cake
摘要:题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=23543 1. 因为没有三个点在同一直线上,即每个点都是多边形的一个顶点而不会有点在某条边上,所以要判断这个多边形是不是凸多边性,可以用像凸包问题那样做,得到的凸包的关节点 阅读全文

posted @ 2016-03-26 20:51 SuperChan 阅读(243) 评论(0) 推荐(0)

UVAlive - 3516 —— Exploring Pyramids
摘要:题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27284 这道题要我们求树的个数,是一道枚举的题目,关键在于不重不漏地去枚举 这里给出了一种思路: 每一次固定一种“最左边的儿子节点的子树”,剩下的节点任意排布。 然后,通 阅读全文

posted @ 2016-03-25 13:25 SuperChan 阅读(216) 评论(0) 推荐(0)

1

导航