
DP
文章平均质量分 84
码代码的猿猿的AC之路
人一我百,人十我万追逐青春的梦想,怀着自信的心,永不放弃
展开
-
CodeForces 364 B. Free Market
B. Free Markettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohn Doe has recently found a "Free Market" i原创 2013-11-21 16:59:59 · 1476 阅读 · 0 评论 -
CodeForces 366C Dima and Salad
C. Dima and Saladtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima, Inna and Seryozha have gathered in a原创 2013-11-25 21:44:47 · 1723 阅读 · 0 评论 -
CodeForces 375 B. Maximum Submatrix 2
写法似乎太暴力了。。。B. Maximum Submatrix 2time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are giv原创 2013-12-25 15:58:33 · 1569 阅读 · 0 评论 -
USACO Number Triangles
Number TrianglesConsider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on th原创 2014-02-02 09:45:22 · 1558 阅读 · 0 评论 -
HDOJ 1011 Starship Troopers
树形背包。。。。Starship TroopersTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9096 Accepted Submission(s): 2528Problem Descript原创 2014-02-05 21:55:31 · 1231 阅读 · 0 评论 -
HDOJ 2196 Computer
经典的树形DP。。。ComputerTime Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u[Submit] [Go Back] [Status] DescriptionA school bought the原创 2014-02-05 16:38:38 · 1141 阅读 · 0 评论 -
POJ 3107 Godfather
树形DPGodfatherTime Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u[Submit] [Go Back] [Status] DescriptionLast years Chicago was原创 2014-02-05 00:08:25 · 1242 阅读 · 0 评论 -
ZOJ 3201 Tree of Tree
树形背包。。。Tree of TreeTime Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu[Submit] [Go Back] [Status] DescriptionYou're given a原创 2014-02-05 16:40:41 · 1176 阅读 · 0 评论 -
HDOJ 1561 The more, The Better
简单的树形背包。。。The more, The BetterTime Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u[Submit] [Go Back] [Status] DescriptionACboy很喜原创 2014-02-05 19:47:33 · 1231 阅读 · 0 评论 -
ZOJ 3582 Back to the Past
dp[i][j]记录从当前状态到结束状态的期望。。。dp[i][j]=1+segma( dp[i+a][j+b]*P(a,b) ) a 0..n-i b 0..n-j递归就可以了,a==0&&b==0的时候要特判一下Back to the PastTime Limit: 2 Seconds Memory Limit: 65536 KB Spe原创 2014-02-23 00:38:21 · 1683 阅读 · 0 评论 -
HDOJ 3401 Trade
单调队列优化DP :dp[ i ] [ j ] = max{ dp[ i-1 ] [ j ] , dp[ i - w -1 ] [ k ] - ( j - k )*ap[ i ] , dp [ i - w - 1 ] [ k ] + ( k - j )*bp[ i ] }后两项 dp [ i - w - 1 ][ k ] + k* xx - j * xx 且 abs( j -原创 2014-02-25 01:22:48 · 1550 阅读 · 0 评论 -
ZOJ 3349 Special Subsequence
线段树优化DP。。。。Special SubsequenceTime Limit: 5000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu[Submit] [Go Back] [Status] DescriptionThere a s原创 2014-02-25 14:52:18 · 1302 阅读 · 0 评论 -
ZOJ 3723 Starfruit
恶心的状压DP。。。与炮兵阵地类似。。。多了两个方向。而且发射的炮弹可能被石头挡住。。。。1.因为方向是对称的,所以可以把下面两条边翻上来,考虑这样只要考虑上面的行就行了。。。。2.被石头挡住。。。可以模拟一下3.卡内存。。。。要用滚动数组+把可能的状态存下来StarfruitTime Limit: 4 Seconds Memory Limit:原创 2014-02-27 22:37:29 · 1501 阅读 · 0 评论 -
HDOJ 4118 Holiday's Accommodation
每条边要走的次数刚好的是这条边两端的点数的最小值的两倍。Holiday's AccommodationTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 200000/200000 K (Java/Others)Total Submission(s): 2116 Accepted Submission(s): 5原创 2014-03-04 21:07:59 · 3704 阅读 · 0 评论 -
HDOJ 3485 Count 101
数位DP。。。。Count 101Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 912 Accepted Submission(s): 477Problem DescriptionYou原创 2014-03-10 23:06:22 · 1122 阅读 · 0 评论 -
HDOJ 4604 Deque
DequeTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2054 Accepted Submission(s): 746Problem DescriptionToday, the teacher ga原创 2014-03-09 00:13:42 · 1266 阅读 · 0 评论 -
SERC2013 J You Win!
装压DP......http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11450J: You Win!You just achieved the High Score on your favorite video game! Now, you get to enter your name! You h原创 2014-03-16 23:13:10 · 1788 阅读 · 0 评论 -
HDOJ 4632 Palindrome subsequence
区间DP。。。。Palindrome subsequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65535 K (Java/Others)Total Submission(s): 2021 Accepted Submission(s): 836Problem Desc原创 2014-03-30 00:44:12 · 1353 阅读 · 0 评论 -
Codeforces 417 D. Cunning Gena
按monitor排序,然后状压DP。。。。D. Cunning Genatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy n原创 2014-04-18 10:45:41 · 2519 阅读 · 2 评论 -
HDOJ 4283 You Are the One
dp[i][j] 表示从第i个人到第j个人的最小花费。。。仅考虑这j-i+1个人,对第i个人而言,如果第i个人第k个出去,那么i+1到i+1+k-1-1个人都在第i个人之前出去了,这里就是一个子问题 dp[i+1][i+1+k-1-1],i出去要加上(k-1)*D[i],i+k个人到j个人肯定是在i之后出去的这里是另一个子问题dp[i+k][j],不过这些人已经等了k个人所以还要加上sum[i原创 2014-04-02 20:40:21 · 1273 阅读 · 0 评论 -
HDOJ 2089 不要62
超级简单的数位DP....不要62Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17584 Accepted Submission(s): 5800Problem Description杭原创 2014-05-05 20:51:41 · 1407 阅读 · 0 评论 -
POJ 2168 Joke with Turtles
脑子一抽用0初始化DP。。。TLE到爆了。。。。Joke with TurtlesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1203 Accepted: 319 Special JudgeDescriptionTher原创 2014-04-04 14:18:59 · 1173 阅读 · 0 评论 -
HDOJ 4293 Groups
水DP。。。GroupsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1133 Accepted Submission(s): 440Problem Description After原创 2014-04-03 23:51:27 · 988 阅读 · 0 评论 -
POJ 2955 Brackets
简单的区间DP。。。BracketsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2518 Accepted: 1300DescriptionWe give the following inductive definition of原创 2014-04-04 16:24:23 · 923 阅读 · 0 评论 -
HDOJ 4649 Professor Tian
按位DP。。。。。Professor TianTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 661 Accepted Submission(s): 360Problem Description原创 2014-04-05 23:26:19 · 969 阅读 · 0 评论 -
Codefroces 429 B. Working out
DP预处理出到4个顶点的最大距离,枚举相交的点B. Working outtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSummer is c原创 2014-05-14 16:15:27 · 1386 阅读 · 0 评论 -
ZOJ 3791 An Easy Game
这种数据范围一看就想到DP....dp[i][j]:在第i轮有j个不同位置的可能的方法数,配合组合数搞一搞就可以了。。。注意超INTAn Easy GameTime Limit: 2 Seconds Memory Limit: 65536 KBOne day, Edward and Flandre play a game. Flandre will原创 2014-06-07 21:09:21 · 1352 阅读 · 0 评论 -
Codeforces 431 D. Random Task
很巧妙的单调性......n,n+1,n+2,.....2*n-2 n+1,n+2,.....2*n-2,2*n-1,2*n中间一段是相同的,n和2*n里的1是一样多的所以只有2*n-1不一样.....这是满足单调性的(monotone)然后就是数位DP了.....D. Random Tasktime limit per te原创 2014-05-26 21:18:34 · 1550 阅读 · 0 评论 -
HDOJ 4870 Rating
概率DP.....RatingTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 229 Accepted Submission(s): 140Special JudgeProblem Des原创 2014-07-23 12:48:19 · 1132 阅读 · 0 评论 -
HDOJ 4865 Peter's Hobby
隐马尔可夫模型介绍见这里:点击打开链接Peter's HobbyTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 362 Accepted Submission(s): 160Problem De原创 2014-07-24 01:11:00 · 1386 阅读 · 0 评论 -
POJ 2677 Tour
双调欧几里得 DPTourTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3581 Accepted: 1596DescriptionJohn Doe, a skilled pilot, enjoys tra原创 2014-08-01 00:58:24 · 1128 阅读 · 0 评论 -
HDOJ 4901 The Romantic Hero
DP....扫两遍组合起来The Romantic HeroTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 547 Accepted Submission(s): 217Problem Desc原创 2014-07-31 23:14:04 · 972 阅读 · 0 评论 -
Codeforces 155 C. Hometask
DP....C. Hometasktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSergey attends lessons of the N原创 2014-08-01 21:53:40 · 1049 阅读 · 0 评论 -
Codeforces Round #FF 446A DZY Loves Sequences
预处理出每个数字可以向后延伸多少,然后尝试将两段拼起来。C. DZY Loves Sequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2014-07-14 18:48:04 · 1144 阅读 · 0 评论 -
LightOJ 1205 Palindromic Numbers
数位DP。。。。Palindromic NumbersTime Limit: 2000MSMemory Limit: 32768KB64bit IO Format: %lld & %llu[Submit] [Go Back] [Status] DescriptionA palindro原创 2014-07-31 00:08:03 · 2048 阅读 · 0 评论 -
Codeforces 453 B. Little Pony and Harmony Chest
状压DP.....B. Little Pony and Harmony Chesttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputP原创 2014-08-02 15:37:09 · 1025 阅读 · 0 评论 -
Codeforces 346 B. Lucky Common Subsequence
LCS+一维KMP构造转移+记忆化搜索。。。。B. Lucky Common Subsequencetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outp原创 2014-09-04 19:51:46 · 2077 阅读 · 0 评论 -
Codeforces 362C. Insertion Sort
DP预处理+枚举逆序对C. Insertion Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya is a beg原创 2014-09-04 23:31:19 · 1265 阅读 · 0 评论 -
POJ 1160 Post Office
N个数到一个数的距离和最小,这个数一定是他们的中位数。dp[i][j]=前i个点,j个office的距离。dp[i][j]=min(dp[k-1][j-1]+w[k][i]) w[k][i]是k..i 修一个office的距离。Post OfficeTime Limit: 1000MS Memory Limi原创 2014-08-07 22:06:00 · 970 阅读 · 0 评论 -
Codeforces 208 B. Solitaire
记忆化搜索dp【还剩下几个】【倒1】【倒2】【倒3】CF JAVA中 public static class 前面好像不能再开类了,连注释掉的类也不可以,好像是个BUG???B. Solitairetime limit per test2 secondsmemory limit per test256 megabyte原创 2014-09-06 00:03:14 · 1419 阅读 · 0 评论