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 as many transactions as you like (ie, buy on...
分类:
编程语言 时间:
2014-07-24 10:25:36
阅读次数:
227
题目链接题意:给出几个基因片段,要求你将它们排列成一个最短的序列,序列中使用了所有的基因片段,而且不能翻转基因。分析:先计算出add数组,再dfs枚举。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7...
分类:
其他好文 时间:
2014-07-23 22:11:17
阅读次数:
281
http://acm.hdu.edu.cn/showproblem.php?pid=4864【题意】 有n个机器每个机器都有一个最长工作时间和等级,m个任务,每个任务有一个需要花费的时间和任务等级,每个任务完成了可以得打到500*time+2*rank 块钱,一个机器只能对应做一个时间和等级都 .....
分类:
其他好文 时间:
2014-07-23 16:30:41
阅读次数:
241
跟导师请假,邮件如下:Title: Ask for leave in April 30thDear Mentor XXX:I'm requesting a leave of absence in April 30th for attending a wedding.Best regards,yyy
分类:
其他好文 时间:
2014-07-22 22:46:53
阅读次数:
180
class Solution {public: int maxProfit(vector &prices) { int len = prices.size(); if (len i2r(len, 0); vector i2l(len, 0); ...
分类:
其他好文 时间:
2014-07-22 22:34:54
阅读次数:
154
Page Rank就是MapReduce的来源,下文是一个简单的计算PageRank的示例。 import?java.text.DecimalFormat;
/**
?*?Created?by?jinsong.sun?on?2014/7/15.
?*/
public?class?PageRankCaculator?{
??...
分类:
编程语言 时间:
2014-07-21 10:22:18
阅读次数:
301
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-07-20 21:33:36
阅读次数:
204
题意:
n个人站成一排 一开始是从1到n有序的 现在有三个操作 Top操作是将一个人排到队首 Query操作是询问某个人现在排第几 Rank操作是询问排某个位置的人是谁
思路:
将队伍扭来扭去… 很像splay的旋转吧(哪像了!!)
这是个不错的splay题…
首先 n很大 但是操作不多 想到离散化
离散化还有个技巧 我们发现只有top和query操作对单人进行 rank和人没什么关系
所以要把top和query操作的人单独拿出来 那么其他的人就可以用区间的形式来表示了
我们只需要开...
分类:
其他好文 时间:
2014-07-19 23:24:09
阅读次数:
344
The best way to learn DP from DFS! Nice problem.My intuition is that it can be solved by DFS:class Solution {public: int climbStairs(int n) { ...
分类:
其他好文 时间:
2014-07-18 17:24:53
阅读次数:
188
#include#include#include#includestruct rank{char name[12];int sol, tot, g, p[7], ind;//sol 解决题数 tot总时间};rank r[25];int comp(const void *c, const void ...
分类:
其他好文 时间:
2014-07-18 10:29:36
阅读次数:
188