思路:

dp。

实现:

 class Solution
{
public:
int splitArray(vector<int>& nums, int m)
{
int n = nums.size();
vector<int> sum(n + , );
for (int i = ; i <= n; i++) sum[i] = sum[i - ] + nums[i - ];
vector<vector<int>> dp(n + , vector<int>(m + , INT_MAX));
for (int i = ; i <= n; i++) dp[i][] = sum[i];
for (int i = ; i <= n; i++)
{
for (int j = ; j <= min(m, i); j++)
{
for (int k = ; k < i; k++)
{
int tmp = sum[i] - sum[k];
dp[i][j] = min(dp[i][j], max(tmp, dp[k][j - ]));
}
}
}
return dp[n][m];
}
};

leetcode410 Split Array Largest Sum的更多相关文章

  1. [Swift]LeetCode410. 分割数组的最大值 | Split Array Largest Sum

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  2. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  3. Split Array Largest Sum

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  4. Leetcode: Split Array Largest Sum

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  5. 动态规划——Split Array Largest Sum

    题意大概就是,给定一个包含非负整数的序列nums以及一个整数m,要求把序列nums分成m份,并且要让这m个子序列各自的和的最大值最小(minimize the largest sum among th ...

  6. Split Array Largest Sum LT410

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  7. 410. Split Array Largest Sum 把数组划分为m组,怎样使最大和最小

    [抄题]: Given an array which consists of non-negative integers and an integer m, you can split the arr ...

  8. [LeetCode] 410. Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  9. 【leetcode】410. Split Array Largest Sum

    题目如下: Given an array which consists of non-negative integers and an integer m, you can split the arr ...

随机推荐

  1. spring-jar包详解整理(大合集)

    转:https://blog.csdn.net/weisong530624687/article/details/50888094 spring.jar 是包含有完整发布模块的单个jar 包.但是不包 ...

  2. DataSnap Mobile Client Tutorial

    One of my customers was having some difficulty following the DataSnap tutorial which can be found he ...

  3. html5--6-4 CSS选择器

    html5--6-4 CSS选择器 实例 学习要点 掌握常用的CSS选择器 了解不太常用的CSS选择器 什么是选择器 当我们定义一条样式时候,这条样式会作用于网页当中的某些元素,所谓选择器就是样式作用 ...

  4. bzoj 2301 [HAOI2011]Problem b(莫比乌斯反演+分块优化)

    题意:对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 1≤n≤50000,1≤a≤b≤50000, ...

  5. bleve搜索引擎源码分析之索引——mapping和lucene一样,也有_all

    例子: package main import ( "fmt" "github.com/blevesearch/bleve" ) func main() { / ...

  6. php中自运算++ 或-- 的总结

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  7. 【CQ18阶梯赛第一场】题解

    [A-风格不统一如何写程序] 输入字符串,得到长度,对于每个字符:如果是大写,则改为:‘_’+小写:如果是‘_’则忽略‘_’,并且把后面的小写改为大写. #include<cstdio> ...

  8. [SHOI 2015] 脑洞治疗仪

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4592 [算法] 对于操作1 , 我们首先查询区间[l0 , r0]中有多少个1 , ...

  9. 【NOIP2016】 组合数问题

    [题目链接] 点击打开链接 [算法] 杨辉三角 + 二维前缀和 O(1)计算答案 [代码] #include<bits/stdc++.h> using namespace std; #de ...

  10. Ubuntu16.04安装Python3.6 和pip

    root账户,不是root账户,命令前加sudo 安装: 1.add-apt-repository ppa:jonathonf/python-3.6 2.apt-get update 3.apt-ge ...