Largest Sum of Averages
第39天。
今天的题目是Largest Sum of Averages:
一道动态规划的题目,有点想切钢管的问题。
动规方程如下:
$$
dp[i, j] = \left{
\begin{aligned}
\sum_{z=0}^j A[z] & & i = 1\
\underset{ {i-1 \leq t \leq n-1} }{max} { dp[i-1, t] + \frac {\sum_{z=t+1}^n A[z]} {n-t+1} } & & others
\end{aligned}
\right.
$$
1 | double largestSumOfAverages(vector<int>& A, int K) { |