假设你有一个数组,它的第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
SB题,求最小生成树,其中有些边已经给您建好啦。随意暴力即可。 1 #include 2 #include 3 #include 4 using namespace std; 5 int rank[10001],fa[10001],n,m,a[101][101],q,x,y,f1,f2,ans; 6...
分类:
其他好文 时间:
2014-10-03 16:17:54
阅读次数:
209
题目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
题目地址:POJ 1703
种类并查集水题。
代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int bin[600000], rank[600000];
int f...
分类:
其他好文 时间:
2014-10-01 21:37:32
阅读次数:
232
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
入门题
#include
#include
#include
using namespace std;
const int maxn = 50010;
struct edge
{
int v, next;
}e[maxn*2];
int n, m, q;
int first[maxn], cnt;
int top[maxn], tid[maxn], rank[maxn], sz[ma...
分类:
其他好文 时间:
2014-09-29 19:36:51
阅读次数:
252