题目描述 给定 n 个整数组成的序列,将序列分割为 m 段,如何分割才能使这 m 段子序列的和的最大值达到最小? 题解 状态表示 dp[i][j]表示前i个元素划分j段 子序列和的最大值的最小值 状态转移 dp[i][j]=min{dp[i][j], max{dp[k][j-1],dp[i][1]-dp[k][1]}},其中前k个元素是前j-1段,k+1到末尾是最后一段. 初始化 dp[i][1]=对应子数组原始元素和 todo for循环的终止条件还有需继续思考为什么不是注释的?或者换成注释要…
https://scut.online/p/299 \(dp[i][k]\) 为前 \(i\) 个数分 \(k\) 组的最大值,那么 $dp[i][k]=max_{p=1}^{i-1}{dp[p][k-1]*sum(p+1,i)} $ #include<bits/stdc++.h> using namespace std; typedef long long ll; struct BigInt { const static int mod = 10000; const static int D…
1.线性 「BZOJ1609」麻烦的聚餐 分别求一遍连续非下降/上升子序列长度,用总长减去,取最小值即可,主要\(O(n^2)\)优化 Code #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn=3e5+5; typedef long long ll; int n,f[maxn],a[ma…
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He woke up from an egg and split the egg into two parts: the sky and the earth. At the begi…
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He woke up from an egg and split the egg into two parts: the sky and the earth. At the begi…