码迷,mamicode.com
首页 >  
搜索关键字:maximum sum subarray    ( 25087个结果
projecteuler---->problem=6----Sum square difference
title: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence ...
分类:其他好文   时间:2014-06-05 12:03:29    阅读次数:243
Leetcode--Best Time to Buy and Sell Stock III
Problem Description: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transa...
分类:其他好文   时间:2014-06-05 09:33:52    阅读次数:342
hdu 1863 畅通工程
题目:         链接:点击打开链接 题意:         中文题 算法: 思路:         赤裸裸的最小生成树。。 代码: #include #include using namespace std; struct node{ int u,v,w; } e[110]; int p[110]; int n,m,sum,ans; int cmp(node...
分类:其他好文   时间:2014-06-05 03:50:23    阅读次数:232
LeetCode:4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: ...
分类:其他好文   时间:2014-06-05 00:34:06    阅读次数:240
hdu-4578-Transformation-线段树
当一道题目,使用__int64超时,使用int就能A的时候,我想,这个题,不是一个好题。。。。。 add[i]:记录加的lazy标记 mul[i]:记录乘的lazy标记 num[i]:记录数的lazy标记 sum[i][j]:第i段,j次方的和。 除去lazy标记的下放,这完全就是一道水的线段树的题目。。。 lazy标记如何下放呢? 1,首先查看num标记,如果存在,果断下放。 2...
分类:其他好文   时间:2014-06-04 21:41:27    阅读次数:343
HDU基本最*子序列集锦1
最大连续子序列(HDU1003,1231) 最大递增子序列和,sum[i]=max(sum[j])+a[i],j 最长公共子序列,LCS经典算法(HDU1159)。 题解: 实际上,我没看出hdu1003和1231的本质差别,形式上的差别就是记载的东西不一样,一个是记载下标,一个是记载元素。基本就是那么回事吧。很多算法书在讨论时效都会拿这个例子来说明,让大家看到算法的力量,从一个弱渣算法到...
分类:其他好文   时间:2014-06-03 04:19:10    阅读次数:279
ORACLE 按表字段值的不同统计数量
select p.id comperitorId,p.compcorp competitorName, sum(case when c.kindname = 'ATM' then c.num else 0 end) atm, sum(case when c.kindname = 'CRS' then c.num else 0 end) crs, sum(case when c.kindname...
分类:数据库   时间:2014-06-03 03:12:09    阅读次数:211
HLG 2116 Maximum continuous product (最大连续积 DP)
链接:  http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2116 Description Wind and his GF(game friend) are playing a small game. They use the computer to randomly generated a nu...
分类:其他好文   时间:2014-06-03 02:17:13    阅读次数:252
leetcode -day24 Maximum Depth of Binary Tree & Binary Tree Zigzag Level Order Traversal
1、Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. clas...
分类:其他好文   时间:2014-06-02 23:13:22    阅读次数:290
hdu-1255-覆盖的面积-线段树
记录3个变量。 sum[i]:当前区间被覆盖2次及两次以上的面积。 num[i]:当前区间被覆盖1次及一次以上的面积。 cover[i]:覆盖的lazy标记。 对于每一个区间. 更新操作如下: void push_up(int_now) { if(cover[rt]==0) { num[rt]=num[rt<<1]+num[rt<<1|1]; ...
分类:其他好文   时间:2014-05-31 17:58:57    阅读次数:296
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!