/*
现在有n项工作,知道每一项工作的开始时间和结束时间,问最多可以选择多少工作
算法设计:贪心算法,不断选择不冲突的那些结束时间最短的工作
*/
#include
#include
#define max_n 100001
using namespace std;
int N;
//first is the start of the job,and the secone is...
分类:
编程语言 时间:
2015-04-03 09:27:33
阅读次数:
142
/*
poj 3253 fence repair
题意是说有一个人想要修东西,需要去将一根木头砍成N
段长度指定的木头,现在给定这根木头需要的长度集合
问最少花费是多少
算法设计:贪心的去选择较短的合成,每次都选择最短的两条
最后合成一根木头,也就是还原成原来的总长度
*/
#include
#include
#include
using namespac...
分类:
其他好文 时间:
2015-04-03 09:24:43
阅读次数:
144
/*
直线上有N个点,点x的位置是xi(距最左端),现在要加上标记
对于每个点,要求是在一个为R的圆的范围内需要一个点被标记
问最少需要标记多少个点
算法设计: 贪心算法设计
从左端第一点开始,距离其最远的不超过R的那个点加上标记,然后将那个
被标记的点当作第一个点,向后找那个距离其最远的不超过R的那个点,然后
加上标记,一直这样做下去直到覆盖...
分类:
其他好文 时间:
2015-04-03 00:22:30
阅读次数:
115
/* poj 3617 best cow line
题意为给定长度为N的字符串S,需要构造出长度为N的字符串T,开始的时候T是一个空串
随后只能反复从S的开始或者结尾的地方取一个字符接到T的末尾,要求是根据这个规则
构造出字典序尽可能小的字符串T
算法设计:每次都比较末尾和开头的字符,如果不想等,则选择字典序较小的那个字符
接到T的末尾,这样构造出来的...
分类:
其他好文 时间:
2015-04-02 22:37:59
阅读次数:
181
起源:自动编码器单自动编码器,充其量也就是个强化补丁版PCA,只用一次好不过瘾。于是Bengio等人在2007年的 Greedy Layer-Wise Training of Deep Networks中,仿照stacked RBM构成的DBN,提出Stacked AutoEncoder,为非监督学...
分类:
Web程序 时间:
2015-03-30 18:13:46
阅读次数:
217
This is simple, use greedy algorithm will solve the problem. 1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 int len = pr...
分类:
其他好文 时间:
2015-03-18 07:46:55
阅读次数:
155
题目:WallTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 119 Accepted Submission(s): 47 Problem DescriptionOnce upon a time there was a greedy King w...
分类:
其他好文 时间:
2015-03-16 21:19:04
阅读次数:
180
题目大意:
给你一个N个点,M条边的有向图G,每一条边有两个属性:cost,time。然后要你求出一个环T使得Σcost[u]/Σtime[v](u,v∈T)Σcost[u]/Σtime[v](u,v∈T)最大。
解题思路:
我们要求最大值,一个很直观的思路就是二分答案,然后那么题目就变为询问是否存在一个环T使得使得Σcost[u]/Σtime[v](u,v∈...
分类:
其他好文 时间:
2015-03-11 23:30:08
阅读次数:
223
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is t...
分类:
编程语言 时间:
2015-03-03 09:59:06
阅读次数:
165
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine ...
分类:
编程语言 时间:
2015-03-03 09:58:55
阅读次数:
134