hdoj 1506&&1505(City Game) dp】的更多相关文章

// l表示从l[i]到i连续大于a[i]的最远左区间.r表示从i到r[i]连续大于a[i]的最远又区间 DP 找出 a[i] 的最远左区间和最远右区间与自己连着的比自己大的数的长度 , 然后用这个长度乘以 a[i], 乘积最大的那个就是答案 hdoj 1506 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define N 100000+10 #define…
题目: Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况.由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视.中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共…
题目链接 题意: 给定一棵树,每条边有黑白两种颜色,初始都是白色,现在有三种操作: 1 u v:u到v路径(最短)上的边都取成相反的颜色 2 u v:u到v路径上相邻的边都取成相反的颜色(相邻即仅有一个节点在路径上) 3 u v:查询u到v路径上有多少个黑色边 思路: 对树进行树链剖分,分成重链和轻链,用两棵线段树W,L来维护.W维护树上在重链上的u和v之间的边的翻转情况(操作在线段树上的[pos[v],pos[u]]区间):L维护树上在重链上的u和v之间的相邻边的翻转情况.那么某一个点u与它父…
House Man Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2256    Accepted Submission(s): 896 Problem Description In Fuzhou, there is a crazy super man. He can't fly, but he could jump from hou…
Problem Description Calculate S(n). S(n)=1^3+2^3 +3^3 +--+n^3 . Input Each line will contain one integer N(1 < n < 1000000000). Process to end of file. Output For each case, output the last four dights of S(N) in one line. Sample Input 1 2 Sample Ou…
Problem Description Now give you two integers n m, you just tell me the m-th number after radix point in 1/n,for example n=4,the first numble after point is 2,the second is 5,and all 0 followed Input Each line of input will contain a pair of integers…
Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin. this puzzle describes that: gave a and b,how to know…
Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him? Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap y…
Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on the game. Members place their bets on the sum of the tw…
题目: Problem Description In 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 consecutive metallic sticks which are of the same length. Now Pudge wants to do some operations…