假设你有一个数组,它的第i个元素是一个股票在一天的价格。
设计一个算法,找出最大的利润。...
分类:
其他好文 时间:
2014-10-04 16:57:46
阅读次数:
122
3394: [Usaco2009 Jan]Best Spot 最佳牧场Time Limit:1 SecMemory Limit:128 MBSubmit:11Solved:9[Submit][Status]DescriptionInput第1行输入三个整数P,FC.之后F行每行输入一个整数表示一个贝...
分类:
其他好文 时间:
2014-10-04 02:35:05
阅读次数:
336
题目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...
分类:
其他好文 时间:
2014-10-03 13:37:34
阅读次数:
225
3300: [USACO2011 Feb]Best ParenthesisTime Limit:10 SecMemory Limit:128 MBSubmit:89Solved:42[Submit][Status]DescriptionRecently, the cows have been com...
分类:
其他好文 时间:
2014-10-03 13:23:44
阅读次数:
356
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...
分类:
其他好文 时间:
2014-10-02 13:58:53
阅读次数:
321
Why, every fault’s condemn’d ere it be done:Mine were the very cipher of a function. . .—William Shakespeare, Measure for MeasureThe best thing about ...
分类:
编程语言 时间:
2014-10-01 14:47:31
阅读次数:
190
给定长度为N的字符串S,构造长度为N的字符串T,起初T是空串,反复从S的头部或者尾部删除一个字符,加到T的尾部。目标是构造字典序尽可能小的T。尝试如下贪心算法:不断取S头部和尾部较小的字符放到T的尾部。考虑S头部和尾部字符相同的情况。有如下算法:按照字典序比较S和将S反转后的字符串S‘;如果S较小,...
分类:
其他好文 时间:
2014-09-30 20:28:10
阅读次数:
207
一定要判断好边界条件,edge case很关键。 1 #include 2 #include 3 using namespace std; 4 5 class Solution { 6 public: 7 int maxProfit(vector &prices) { 8 ...
分类:
其他好文 时间:
2014-09-27 19:02:20
阅读次数:
202
技巧及注意:细节方面十分重要,你要想啊,敢出模拟题一定有出模拟题的原因~出题人一定会放很多坑给你,所以在码之前一定要先有大概的思路框架,然后在写代码中思考比如说这题:【BZOJ】3300: [USACO2011 Feb]Best Parenthesis(模拟)一开始我没注意边界问题,所以一直爆wa。...
分类:
其他好文 时间:
2014-09-26 09:03:38
阅读次数:
195
Problem:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transac...
分类:
其他好文 时间:
2014-09-25 21:10:47
阅读次数:
171