摘要: 简单DP三角形左右取最大值就好,然后计算到最后一行时再取最大值。#include#includeusing namespace std;int main(){ int a[101][101],n,i,j; while(scanf("%d",&n)!=-1) { for(i=1;ia[i-1][j]? a[i-1][j-1]:a[i-1][j]); } a[i][i] += a[i-1][j-1]; } int mmax=a[n][1]; for(i=1;immax) mmax=... 阅读全文
posted @ 2014-04-04 11:57 霖‘ 阅读(75) 评论(0) 推荐(0) 编辑
摘要: Mayor's postersTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 37982Accepted: 11030DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has fi 阅读全文
posted @ 2014-03-23 09:29 霖‘ 阅读(125) 评论(0) 推荐(0) 编辑
摘要: LCISTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3553Accepted Submission(s): 1577Problem DescriptionGiven n integers.You have two operations:U A B: replace the Ath number by B. (index counting from 0)Q A B: output the length of the longest conse 阅读全文
posted @ 2014-03-23 08:57 霖‘ 阅读(157) 评论(0) 推荐(0) 编辑
摘要: A Simple Problem with IntegersTime Limit: 5000MSMemory Limit: 131072KTotal Submissions: 54392Accepted: 16353Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a gi 阅读全文
posted @ 2014-03-23 08:51 霖‘ 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Just a HookTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14770Accepted Submission(s): 7315Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecu 阅读全文
posted @ 2014-03-23 08:46 霖‘ 阅读(107) 评论(0) 推荐(0) 编辑
摘要: I Hate ItTime Limit: 9000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 32300Accepted Submission(s): 12787Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每 阅读全文
posted @ 2014-03-18 14:52 霖‘ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1400结构体排序+树状数组模板..#include#include#includeusing namespace std;int c[100009];struct point{ int x; int v;} p[100000];bool cmp(point p1,point p2){ if(p1.x !=p2.x) return p1.x>p2.x; else return p1.v0)... 阅读全文
posted @ 2014-03-12 20:25 霖‘ 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3928乒乓比赛,有N个人参加,输入每个玩家的技能等级,对每个人设置一个特定ID和一个技能值,一场比赛需要两个选手和一个裁判,只有当裁判的ID和技能值都在两个选手之间的时候才能进行一场比赛,现在问一共能组织多少场比赛。参考的其他人的代码,重新敲了一遍。/*POJ 3928Ping pong*/#include#include#includeusing namespace std;#define N 23000int c[N],n;long long int ans;struct Node{ int id; int lev... 阅读全文
posted @ 2014-03-12 20:21 霖‘ 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2299用了树状数组,求逆序数。读入这些数,每读一个数就update一次,看一下它前面比它小的已出现过的有多少个sum(),然后用当前的位置-当前的sum(),就可以得到当前逆序对数了,加起来就得到总的逆序对数。#include#include#includeusing namespace std;#define N 500010int n,c[N],reflect[N];struct Node{ int val; int pos;} node[N];bool cmp(Node a,Node b){ return ... 阅读全文
posted @ 2014-03-12 18:54 霖‘ 阅读(107) 评论(0) 推荐(0) 编辑
摘要: A.Rescue The PrincessDescriptionSeveral days ago, a beast caught a beautiful princess and the princess was put in prison. To rescue the princess, a prince who wanted to marry the princess set out immediately. Yet, the beast set a maze. Only if the prince find out the maze’s exit can he save the prin 阅读全文
posted @ 2014-03-10 16:20 霖‘ 阅读(137) 评论(0) 推荐(0) 编辑