题目:
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 k transactions.
Note:
Y...
分类:
编程语言 时间:
2015-07-26 15:56:12
阅读次数:
142
题目:
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 transactions.
Note:
...
分类:
编程语言 时间:
2015-07-26 15:53:12
阅读次数:
155
题意:给定一个长度为N的数组,求两个连续的子序列,使得两个连续子序列的和最大。
分析:乍一看,跟最大连续和有点类似,但是,又有区别,因为对于这个题,考虑第i项两个连续子序列的最大和,不能仅仅由前i-1项递推得出,第i项两个连续子序列的最大和,与前i项和i以后的之间是存在关系的,因此这个题目是一个双向dp。
假如给定的序列为a0, a1, a2, a3, a4, ...... ,an,那么,对于...
分类:
其他好文 时间:
2015-07-26 11:15:59
阅读次数:
144
RMQ (Range Minimum/Maximum Query)问题是指:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在i,j里的最小(大)值,也就是说,RMQ问题是指求区间最值的问题。...
分类:
其他好文 时间:
2015-07-25 21:37:41
阅读次数:
125
A - Maximum sum
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status Practice POJ
2479
Description
Given a set of n integers: A={a1, a2,..., a...
分类:
其他好文 时间:
2015-07-25 18:29:19
阅读次数:
165
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2015-07-24 20:41:53
阅读次数:
82
I love developing software on my MacBook Air! I got the latest version with the maximum possible specifications (i7, 8GB internal mem, 512GBSSD disk) ...
分类:
系统相关 时间:
2015-07-24 12:31:18
阅读次数:
221
题目https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/
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...
分类:
其他好文 时间:
2015-07-24 09:22:28
阅读次数:
125
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [?2,1,?3,4,?1,2,1,?5,4],
the contiguous subarray [4,?1,2,1] has the...
分类:
其他好文 时间:
2015-07-22 20:58:27
阅读次数:
127
water~数据不大,枚举首尾即可,也不用高精度。代码如下:#includeint main() { int kase(0), n; while (scanf("%d", &n) == 1) { int s[20]; for (int i = 0; i != n; ++i) scanf("%d", ...
分类:
其他好文 时间:
2015-07-22 13:01:41
阅读次数:
127