斜率优化。 大水题。。。 #include #include #include using namespace std; const int maxn = 1000000 + 10; int q[maxn],l,r; long long f[maxn],s[maxn],a,b,c,x; int n,... ...
1912: [Apio2010]patrol 巡逻 Description Input 第一行包含两个整数 n, K(1 ≤ K ≤ 2)。接下来 n – 1行,每行两个整数 a, b, 表示村庄a与b之间有一条道路(1 ≤ a, b ≤ n)。 Output 输出一个整数,表示新建了K 条道路后能 ...
分类:
其他好文 时间:
2016-05-21 15:47:56
阅读次数:
160
想了好久啊.。。。 用了我感觉比较好写的一种(因为没写过维护凸包),另一种是维护凸包的做法,本质一样?推荐http://www.mamicode.com/info-detail-345781.html。 网上的大多数解法: DP:f[i]=max(f[j]+a*(sum[i]-sum[j])^2+b ...
[BZOJ1911][Apio2010]特别行动队 试题描述 输入 输出 输入示例 输出示例 数据规模及约定 题解 DP,令 f(i) 表示前 i 个士兵可以达到的最大修正后的战斗力,则有 f(i) = max{ f(j) + d(j+1 ~ i) | 0 < j < i },其中d(i ~ j)表 ...
1911: [Apio2010]特别行动队 Description Input Output Sample Input 4 -1 10 -20 2 2 3 4 Sample Output 9 HINT Source Solution 题意非常明显,将n个数划分成多段区间,使得总价值最大,每段区间的价 ...
分类:
其他好文 时间:
2016-04-11 22:23:47
阅读次数:
184
Description Input Output Sample Input 4 -1 10 -20 2 2 3 4 Sample Output 9 HINT 转移方程 f[i]=max(f[j]+a*(h[i]-h[j])^2+b*(h[i]-h[j])+c) //h数组为前缀和 如此显然的方程复杂
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1911DescriptionInputOutput斜率优化DP教主的题解:http://www.cnblogs.com/JSZX11556/p/4811459.html我也懒得写下去了…… 1...