随笔分类 - 动态规划(DP)
摘要:题目1533:最长上升子序列http://ac.jobdu.com/problem.php?pid=1533时间限制:1 秒内存限制:128 兆特殊判题:否提交:857解决:178题目描述:给定一个整型数组, 求这个数组的最长严格递增子序列的长度。 譬如序列1 2 2 4 3 的最长严格递增子序列为1,2,4或1,2,3.他们的长度为3。输入:输入可能包含多个测试案例。对于每个测试案例,输入的第一行为一个整数n(1#include#include#includeusing namespace std;const int N=110000;int n,val[N];vector vt;int b
阅读全文
摘要:题目4:棋盘寻宝扩展http://ac.jobdu.com/problem.php?cid=1048&pid=3时间限制:1 秒内存限制:128 兆特殊判题:否提交:59解决:32题目描述:现在有一个8*8的棋盘,上面放着64个不同价值的礼物,每个小的棋盘上面放置一个礼物(礼物的价值大于0小于100),一个人初始位置在棋盘的左上角,每次他只能向下或向右移动一步,并拿走对应棋盘上的礼物,结束位置在棋盘的右下角。从棋盘的左上角移动到右下角的时候的,每次他只能向下或向右移动一步,并拿走对应棋盘上的礼物,但是拿到的所有的礼物的价值之和不大于一个限定值limit,请设计一个算法请实现,使其能够获
阅读全文
摘要:StringTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 158Accepted Submission(s): 69Problem DescriptionGiven 3 strings A, B, C, find the longest string D which satisfy the following rules:a) D is the subsequence of Ab) D is the subsequence of Bc) C
阅读全文
摘要:Divide ChocolateTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1465Accepted Submission(s): 682Problem DescriptionIt is well known that claire likes dessert very much, especially chocolate. But as a girl she also focuses on the intake of calories e
阅读全文
摘要:Palindrome subsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/65535 K (Java/Others)Total Submission(s): 558Accepted Submission(s): 203Problem DescriptionIn mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing
阅读全文
摘要:湫秋系列故事——安排座位Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 454Accepted Submission(s): 137Problem Description 为了给腾讯公司找到更多优秀的人才,HR湫秋最近去某高校组织了一次针对该校所有系的聚会,邀请了每个系的一些优秀学生来参加。 作为组织者,湫秋要安排他们的座位。这并不是一件很简单的事情,因为只有一排位置,并且位置总数恰好等于参加聚会的人数。为了促进交流,两个来自相同系的同..
阅读全文
摘要:威威猫系列故事——打地鼠Time Limit: 300/100 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 755Accepted Submission(s): 416Problem Description 威威猫最近不务正业,每天沉迷于游戏“打地鼠”。 每当朋友们劝他别太着迷游戏,应该好好工作的时候,他总是说,我是威威猫,猫打老鼠就是我的工作! 无话可说... 我们知道,打地鼠是一款经典小游戏,规则很简单:每隔一个时间段就会从地下冒出一只或多只地鼠,玩游戏的人要做的就是...
阅读全文
摘要:Human Gene FunctionsTime Limit:1000MSMemory Limit:10000KTotal Submissions:15269Accepted:8469DescriptionIt is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in iden
阅读全文
摘要:PearlsTime Limit:1000MSMemory Limit:10000KTotal Submissions:6383Accepted:3084DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delivers to the royal family of Pearlania. But i
阅读全文
摘要:AlignmentTime Limit:1000MSMemory Limit:30000KTotal Submissions:10804Accepted:3464DescriptionIn the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his soldiers are
阅读全文
摘要:The Cow LexiconTime Limit:2000MSMemory Limit:65536KTotal Submissions:7088Accepted:3299DescriptionFew know that the cows have their own dictionary withW(1 ≤W≤ 600) words, each containing no more 25 of the characters 'a'..'z'. Their cowmunication system, based on mooing, is not very ac
阅读全文
摘要:ZipperTime Limit:1000MSMemory Limit:65536KTotal Submissions:14127Accepted:4962DescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its or
阅读全文
摘要:Mondriaan's DreamTime Limit:3000MSMemory Limit:65536KTotal Submissions:9135Accepted:5280DescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series' (where he had to use his toilet paper to draw on, f
阅读全文
摘要:Most PowerfulTime Limit:2 Seconds Memory Limit:65536 KBRecently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power is produced. Researchers know the way every t
阅读全文
摘要:Islands and BridgesTime Limit:4000MSMemory Limit:65536KTotal Submissions:7729Accepted:1977DescriptionGiven a map of islands and bridges that connect these islands, a Hamilton path, as we all know, is a path along the bridges such that it visits each island exactly once. On our map, there is also a p
阅读全文
摘要:Hie with the PieTime Limit:2000MSMemory Limit:65536KTotal Submissions:2969Accepted:1505DescriptionThe Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait fo
阅读全文
摘要:炮兵阵地Time Limit:2000MSMemory Limit:65536KTotal Submissions:14869Accepted:5575Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示:如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域:沿
阅读全文
摘要:Corn FieldsTime Limit:2000MSMemory Limit:65536KTotal Submissions:4876Accepted:2573DescriptionFarmer John has purchased a lush new rectangular pasture composed ofMbyN(1 ≤M≤ 12; 1 ≤N≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squ
阅读全文
摘要:Aeroplane chessTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 660Accepted Submission(s): 468Problem DescriptionHzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws
阅读全文
摘要:MazeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1055Accepted Submission(s): 347Special JudgeProblem DescriptionWhen wake up, lxhgww find himself in a huge maze.The maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms
阅读全文