随笔分类 -  动态规划

摘要:题意: 一个树形图,有个二货商人,旅游时候还想着赚钱!从某个地方到另一个地方时,可以旅途中进一批货(应该人手不够,手里只能拿一批),然后在旅途中卖掉,求最大能赚多少钱。思路: LCA,ans(x,y)=max(up(x,lca),down(lca,y),maxp(lca,y)-min(lca,x... 阅读全文
posted @ 2014-08-29 21:58 Estimator 阅读(349) 评论(0) 推荐(0)
摘要:(ACM ICPC 2013–2014, NEERC, Northern Subregional Contest)Flight Boarding OptimizationInput file: flight.inOutput file: flight.outTime limit: 2 seconds... 阅读全文
posted @ 2014-08-17 11:30 Estimator 阅读(441) 评论(0) 推荐(0)
摘要:经典动态规划 无需单独枚举最后红塔的数量,因为对于dp[i][j],对于红塔的影响仅局限于i,j两个变量,与其前面塔排列无关,故二维动态规划即可。#include #include #include #include #include #include #include #include #inc... 阅读全文
posted @ 2014-08-13 01:48 Estimator 阅读(205) 评论(0) 推荐(0)
摘要:该来的总是要来的————————经典问题,石子合并。 对于 f[i][j]= min{f[i][k]+f[k+1][j]+w[i][j]}From 黑书凸四边形不等式:w[a][c]+w[b][d]#include #define N 1005int s[N][N],f[N][N],sum[N],... 阅读全文
posted @ 2014-08-02 14:07 Estimator 阅读(2604) 评论(2) 推荐(0)
摘要:Little Pony and Harmony Chest经典状态压缩dp#include #include #include #include #define min(x,y) (x>y?y:x)using namespace std;int factor[30],all,n,a[105],b[1... 阅读全文
posted @ 2014-08-02 13:27 Estimator 阅读(344) 评论(0) 推荐(0)
摘要:The Romantic HeroTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Problem DescriptionThere is an old country and the k... 阅读全文
posted @ 2014-07-31 23:19 Estimator 阅读(245) 评论(0) 推荐(0)
摘要:Balanced NumberTime Limit:3000MSMemory Limit:0KB64bit IO Format:%lld & %lluDescriptionA balanced number is a non-negative integer that can be balanced... 阅读全文
posted @ 2014-07-25 16:43 Estimator 阅读(288) 评论(0) 推荐(0)
摘要:RatingTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 578Accepted Submission(s): 363Special Judge... 阅读全文
posted @ 2014-07-25 01:32 Estimator 阅读(258) 评论(0) 推荐(0)
摘要:学这个斜率优化dp却找到这个真心容易出错的题目,其中要从n倒过来到1的确实没有想到,另外斜率优化dp的算法一开始看网上各种大牛博客自以为懂了,最后才发现是错了。不过觉得看那些博客中都是用文字来描述,还是应该用画图来表示更容易让人明白,不过时间不太够,且网上该题解法到处都是,就不累赘了。代码才20几行... 阅读全文
posted @ 2014-03-27 14:48 Estimator 阅读(369) 评论(0) 推荐(0)