摘要: 最大子序列TimeLimit:1 SecondMemoryLimit:32 MegabyteTotalsubmit:156Accepted:42Description给定一个N个整数组成的序列,整数有正有负,找出两段不重叠的连续子序列,使得它们中整数的和最大。两段子序列都可以为空。Input多组输入... 阅读全文
posted @ 2014-10-10 10:14 balfish 阅读(898) 评论(0) 推荐(0) 编辑
摘要: 转自http://blog.csdn.net/zhang360896270/article/details/6701589这题要求最长下降子序列的长度和个数,我们可以增加数组maxlen[size](记录当前第1个点到第i个点之间的最长下降序列长度)和maxnum[size](记录1~i之间的最长下... 阅读全文
posted @ 2014-10-10 10:12 balfish 阅读(485) 评论(0) 推荐(0) 编辑
摘要: 来源:dlut oj1105: Zhuo’s DreamTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 40 Solved: 14[Submit][Status][Web Board]DescriptionZhuo is a lovely boy and ... 阅读全文
posted @ 2014-10-10 10:09 balfish 阅读(248) 评论(0) 推荐(0) 编辑
摘要: poj 1118#includeusing namespace std;#define N 700struct point {int x,y;} pnt[N];int main(){ int n,i,j,k,max,cnt; while(scanf("%d",&n)&&n) { ... 阅读全文
posted @ 2014-10-10 10:06 balfish 阅读(218) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int map[1010][1010];int dis[1010];int n,pos,sum;void init(){ for(int i=0; i> t >> n; pos = n; ... 阅读全文
posted @ 2014-10-10 10:03 balfish 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 各种方式解这道题!!利用map 超时了#include #include #include using namespace std;string s;map in;int main(){ in.clear(); int i=0,num=0; char out[100010][12]; char a[... 阅读全文
posted @ 2014-10-10 10:00 balfish 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 大侠住店TimeLimit:1 SecondMemoryLimit:32 MegabyteTotalsubmit:116Accepted:64Description有一天晚上,一位大侠打败了若干个武林高手,一时高兴就到一家客栈喝了很多酒,以至于烂醉如泥。最后大侠不得不在这个客栈休息,但是这个店里的老... 阅读全文
posted @ 2014-10-10 09:54 balfish 阅读(702) 评论(0) 推荐(0) 编辑
摘要: 递归与分治经典例题要点在于对3*3箱子的讨论#include #include using namespace std;int main(){// freopen("in.txt","r",stdin); int s1[]={0,7,6,5}; int s2[]={0,5,3,1}... 阅读全文
posted @ 2014-10-10 09:53 balfish 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后... 阅读全文
posted @ 2014-10-10 09:49 balfish 阅读(751) 评论(0) 推荐(0) 编辑
摘要: #include#include int main(){ char s[200][71]; char str[71]; int i,depth; strcpy(s[0],"http://www.acm.org/"); i=0; depth=0; while(... 阅读全文
posted @ 2014-10-10 09:48 balfish 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题意:一群匪徒要进入一个酒店。酒店的门有k+1个状态,每个匪徒的参数是:进入时间,符合的状态,携带的钱。酒店的门刚开始状态0,问最多这个酒店能得到的钱数。思路:dp数组为DP[T][K].转移方程dp[i][j]=max(dp[i-1][j],dp[i-1][j-1],dp[i-1][j+1])因为... 阅读全文
posted @ 2014-10-10 09:45 balfish 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/wangjian8006题目大意:有一头奶牛要上太空,他有很多种石头,每种石头的高度是hi,但是不能放到ai之上的高度,并且这种石头有ci个将这些石头叠加起来,问能够达到的最高高度。解题思路:首先对数据进行升序排序,这样才是一个标准的多重背包的问题为什... 阅读全文
posted @ 2014-10-10 09:41 balfish 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个平面二维坐标,对于每个坐标,如果这个坐标跟(0,0)形成的矩形内包含的点数为 k (包含边界,但不包含坐标本身),那么这个坐标就是 level k。输出level 0 - n-1的点数分别是多少。思路:树状数组,线段树稍后写一个线段树版本#include #include #defin... 阅读全文
posted @ 2014-10-10 09:36 balfish 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题意:给一个矩阵,里面有正负数,求子矩阵和的最大值#include #include #include #include using namespace std;int s[105][105],dp[105],n,temp[105];int main(){ // freopen("in.txt... 阅读全文
posted @ 2014-10-09 22:09 balfish 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 回溯算法:回溯算法实际上是一个类似枚举的搜索尝试方法,它的思想是在搜索尝试中寻找问题的解,当发现不满足求解条件时,就“回溯”返回,尝试别的路径。之前介绍的基础算法中的贪婪算法,动态规划等都具有“无后效性”,也就是在分段处理问题时,某状态一旦确定,将不再改变。而多数问题很难找到"无后效性”的阶段划分和... 阅读全文
posted @ 2014-10-09 22:04 balfish 阅读(1002) 评论(0) 推荐(0) 编辑