
acm_动态规划
文章平均质量分 77
kongming_acm
kongming_acm
展开
-
zoj 3551 Bloodsucker 概率DP
In 0th day, there are n-1 people and 1 bloodsucker. Every day, two and only two of them meet. Nothing will happen if they are of the same species, that is, a people meets a people or a bloodsucker mee原创 2011-10-31 13:44:48 · 983 阅读 · 0 评论 -
tyvj 1023 奶牛的锻炼
奶牛Bessie有N分钟时间跑步,每分钟她可以跑步或者休息。若她在第i分钟跑步,可以跑出D_i米,同时疲倦程度增加1(初始为0)。若她在第i分钟休息,则疲倦程度减少1。无论何时,疲倦程度都不能超过M。另外,一旦她开始休息,只有当疲惫程度减为0时才能重新开始跑步。在第N分钟后,她的原创 2011-09-15 12:17:48 · 1310 阅读 · 0 评论 -
hdu 3933 Dark Parth
Problem DescriptionIn the dark path, the single figure is walking difficultly in the listless rainfall. No one knows his real destination.原创 2011-08-16 11:41:14 · 458 阅读 · 0 评论 -
poj 1185 炮兵阵地 在n*m的矩阵中放置炮使其不能互相攻击的最多放置炮的个数
Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队原创 2011-09-14 10:43:29 · 881 阅读 · 0 评论 -
poj 3254 Corn Fields 在n*m的矩阵中放置牛使其不能互相攻击的放置方法
DescriptionFarmer John has purchased a lush new rectangular pasture composed of M byN (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He want原创 2011-09-14 11:46:35 · 669 阅读 · 0 评论 -
hdu 4035 Maze 在树上求逃出去的期望
Problem DescriptionWhen wake up, lxhgww find himself in a huge maze.The maze consisted by N rooms and tunnels connecting these rooms原创 2011-09-13 20:52:38 · 732 阅读 · 0 评论 -
hdu 4028 The time of a day 求前n个数的lcm>=m的子集个数
Problem DescriptionThere are no days and nights on byte island, so the residents here can hardly determine the length of a single day. For原创 2011-09-13 16:35:05 · 691 阅读 · 0 评论 -
hdu 3920 Clear All of Them I 状态压缩DP
Problem DescriptionAcmers have been the Earth Protector against the evil enemy for a long time, now it’s your turn to protect our home.原创 2011-08-15 22:51:02 · 611 阅读 · 0 评论 -
hdu 2196 Computer 求树上每个节点到其他节点的最远距离
Problem DescriptionA school bought the first computer some time ago(so this computer's id is 1). During the recent years the school boug原创 2011-09-13 19:10:56 · 1322 阅读 · 0 评论 -
hdu 4003 Find Metal Mineral K个机器人从S出发遍历树上所有点的经过的最小权值 树形DP
Problem DescriptionHumans have discovered a kind of new metal mineral on Mars which are distributed in point‐like with paths connecting原创 2011-09-04 16:37:02 · 991 阅读 · 0 评论 -
RMQ模板 求区间最大、最小值。 (前提是数组一旦确定便不再频繁更改)
#include#include#include#includeusing namespace std;#define maxs( a , b ) a>b?a:b#define mins( a , b ) a>b?b:aconst int MAX_N = 110005;int d原创 2010-08-30 19:28:00 · 618 阅读 · 0 评论 -
hdu 3853 LOOPS
he planform of the LOOPS is a rectangle of R*C grids. There is a portal in each grid except the exit grid. It costs Homura 2 magic power to原创 2011-07-26 09:29:53 · 537 阅读 · 0 评论 -
uestc 1558 Charitable Exchange 最少时间将价值交换到M以上 DP+线段树
DescriptionHave you ever heard a star charity show called Charitable Exchange? In this show, a famous star starts with a small item which va原创 2011-07-23 16:53:18 · 750 阅读 · 1 评论 -
hdu 3474 Necklace 单调队列 DP
Problem DescriptionYou are given a necklace consists of N beads linked as a circle. Each bead is either crystal or jade.Now, your task is:1.原创 2011-07-23 19:55:56 · 749 阅读 · 0 评论 -
hdu 2851 Beat It 单调队列+DP
Problem DescriptionThere's a monster-attacking game on the Renren's open platform, and the game's background are showing below.Where lies a原创 2011-07-23 21:16:09 · 747 阅读 · 0 评论 -
tyvj 1199 邮票问题 硬币种类M,数量无限,共取N张,最有多少种可能 完全背包恰好 最少
给定一个信封,最多只允许粘贴N(N≤100)张邮票,我们现在有M(M≤100)种邮票,面值分别为:X1,X2……Xm(Xi≤255为正整数),并假设各种邮票都有足够多张。要求计算所能获得的邮资最大范围。即求最大值MAX,使1-MAX之间的每一个邮资都能得到。例如:N=4,有2种邮票,面值分别为1分,4分,于是可以得到1-10分和12分,13分,16分邮资,由于得不到11分和15分,所以邮资的最大范围max=10 输入格式 Input Format 第一行为最多粘贴的邮票张数n。第二行为邮票种原创 2010-11-25 22:09:00 · 1188 阅读 · 0 评论 -
tyvj 1214 硬币问题 完全背包 恰好 最大/最少
FromAdmin☆硬币问题 描述 Description 有n种硬币,面值为别为a[1],a[2],a[3]……a[n],每种都有无限多。给定非负整数s,可以选取多少个硬币使得面值和恰好为s?输出硬币数目最小值和最大值 输入格式 Input Format 第1行n第2行s第3到n+2行为n种不同的面值 输出格式 Output Format 第1行为最小值第2行为最大值 样例输入 Sample Input 36123原创 2010-11-26 11:20:00 · 1219 阅读 · 0 评论 -
tyvj 1052 没有上司的舞会 树形DP
FromAdmin☆没有上司的舞会 描述 Description Ural大学有N个职员,编号为1~N。他们有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。每个职员有一个快乐指数。现在有个周年庆宴会,要求与会职员的快乐指数最大。但是,没有职员愿和直接上司一起与会。 输入格式 Input Format 第一行一个整数N。(1<=N<=6000)<br />接下来N行,第i+1行表示i号职员的快乐指数Ri。(-128<=Ri<=127)<b原创 2011-01-17 22:19:00 · 2173 阅读 · 0 评论 -
tyvj 1047 乘积最大 N个数,K个乘号使得乘积最大
From Admin☆乘积最大 背景 Background NOIP 2000 普及组 第三道原创 2010-09-24 21:43:00 · 1651 阅读 · 1 评论 -
hdu 3433 A Task Process N个人,第i个人完成一个A任务需要时间ai,完成一个B任务需要时间bi, 现在又X个任务A和Y个任务B,求完成所有任务所需要的最短时间。
Problem DescriptionThere are two kinds of tasks, namely A and B. There are N workers and the i-th worker would like to finish one task A原创 2011-09-26 20:30:29 · 4756 阅读 · 0 评论 -
hdu 3450 Counting Sequences 树状数组+DP 求相邻两个数字的绝对值小于等于H并且序列长度的序列个数
Problem DescriptionFor a set of sequences of integers{a1,a2,a3,...an}, we define a sequence{ai1,ai2,ai3...aik}in which 1<=i1<i2<i3<...<ik<原创 2011-10-10 22:02:50 · 964 阅读 · 0 评论 -
zoj 3554 A Miser Boss BFS+DP 减少废状态
There are three different lathes in a factory namely A,B,C. They are all able to work on all kinds of workpieces. And there aren workpieces to be processed, denoted by 1,2,..,n. Due to different i原创 2011-10-31 13:40:04 · 988 阅读 · 1 评论 -
hdu 4109 Instrction Arrangement 求关键路径的长度
Problem DescriptionAli has taken the Computer Organization and Architecture course this term. He learned that there may be dependence between instructions, like WAR (write after read), WAW, RAW.If原创 2011-10-31 12:34:58 · 1329 阅读 · 0 评论 -
hdu 4104 求不能有已知n个数组成的最小的数
Problem DescriptionAll the shops use discount to attract customers, but some shops doesn’t give direct discount on their goods, instead, they give discount only when you bought more than a cer原创 2011-10-31 10:10:45 · 1072 阅读 · 0 评论 -
hdu 4105 Electric wave DP
Problem DescriptionAli was doing a physic experiment which requires him to observe an electric wave. He needs the height of each peak value and valley value for further study (a peak value means t原创 2011-10-30 16:52:13 · 1044 阅读 · 0 评论 -
2011 北京赛区 I bupt 246 Activation
After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazyfan,andluckilyhegotthefirstrelease.Nowheisathome,readytobeginhisjourney. Butbeforestartingthegame,hemustfir原创 2011-10-27 21:09:31 · 761 阅读 · 0 评论 -
1631 Bridging signals nlogn最长上升子序列
'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports原创 2010-07-11 15:53:00 · 473 阅读 · 0 评论 -
1141 Brackets Sequence 括号匹配
Brackets SequenceTime Limit:1000msMemory limit:10000kB题目描述Let us define a regular brackets sequence in the following way:1. Empty sequence is a regular sequence.2. If S is a regular se原创 2010-07-11 09:58:00 · 447 阅读 · 0 评论 -
hdu 3455 Leap Frog
Problem DescriptionJack and Jill play a game called "Leap Frog" in which they alternate turns jumping over each other. Both Jack and Jill can jump a maximum horizontal distance of 10 units in any si原创 2011-10-19 22:29:29 · 682 阅读 · 0 评论 -
joj 2620: Count Square 状态压缩DP N*M的0,1方格,每一个2*2的小方格有一个价值,求整个方格的最大价值
Xiaoming is a 5-year old boy. He has many toys. Among them there is a magic box. On the top of the box there are n * m grids. One can color原创 2011-10-18 20:54:18 · 972 阅读 · 0 评论 -
hdu 3452 Bonsai 求最少去掉多少权值的边使得所有的叶子节点和根节点断开连接
Problem DescriptionAfter being assaulted in the parking lot by Mr. Miyagi following the "All Valley Karate Tournament", John Kreese has原创 2011-10-17 21:13:47 · 651 阅读 · 0 评论 -
Spiders 求树的直径(距离最远的两个点)
One day mum asked Petya to sort his toys and get rid of some of them. Petya found a whole box of toy spiders. They were quite dear to him an原创 2011-10-18 17:21:58 · 1074 阅读 · 0 评论 -
hdu 3449 Consumer 条件背包 有钱w,给出n种选择,每种选择有m[i]个物品,但必须先买盒子,价格p[i],求买的物品的最大价值
Problem DescriptionFJ is going to do some shopping, and before that, he needs some boxes to carry the different kinds of stuff he is going原创 2011-10-10 12:49:54 · 1304 阅读 · 0 评论 -
zoj 3543 Number String 已知排列数的增减顺序,求排列数的个数
The signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutation, write down原创 2011-10-03 22:00:26 · 712 阅读 · 0 评论 -
hdu 4049 Tourism Planning 状态压缩DP
Problem DescriptionSeveral friends are planning to take tourism during the next holiday. They have selected some places to visit. They h原创 2011-10-04 15:24:46 · 903 阅读 · 1 评论 -
poj 2404 Jogging Trails 求走最少距离使得所有边至少都遍历一次并回到原点(即sum+加上最少多少距离使得原图变成欧拉回路) FLOYD+状态压缩DP
DescriptionGord is training for a marathon. Behind his house is a park with a large network of jogging trails connecting water stations.原创 2011-10-03 21:01:53 · 1508 阅读 · 0 评论 -
hdu 3848 CC On The Tree 求树上最近的叶子节点距离
Problem DescriptionCC lives on the tree which has N nodes.On every leaf of the tree there is an apple(leaf means there is only one branc原创 2011-10-04 19:33:19 · 897 阅读 · 0 评论 -
hdu 2929 有n根火柴, 要求组成一个七段数码组成的十进制数, 要求此数是m的倍数, 问此数最大为多少 DP
Problem DescriptionBob has n matches. He wants to compose numbers using the following scheme (that is, digit 0, 1, 2, 3, 4, 5, 6, 7, 8,原创 2011-10-03 17:51:31 · 1739 阅读 · 0 评论 -
tyvj 1086 Elevator
FromVivian Snow☆Elevator 背景 Background 广东汕头聿怀初中 Train#2 Problem4<br /> 描述 Description 现有N种箱子,每种箱子高度H_i,数量C_i。现选取若干箱子堆成一列,且第i种箱子不能放在高度超过A_i的地方。试求最大叠放高度。<br /> 输入格式 Input Format 第一行,一个整数,表示箱子种类N。<br />接下来N行,每行三个整数,表示H_i,A_i,C_i。<br原创 2011-01-17 14:39:00 · 846 阅读 · 0 评论 -
tyvj 1034 给你T的时间和N个任务的开始时间和完成所需时间,让你求最大的空闲时间
尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成。<br />尼克的一个工作日为N分钟,从第一分钟开始到第N分钟结束。当尼克到达单位后他就开始干活。如果在同一时刻有多个任务需要完成,尼克可以任选其中的一个来做,而其余的则由他的同事完成,反之如果只有一个任务,则该任务必需由尼克去写成,假如某些任务开始时刻尼克正在工作,则这些任务也由尼克的同事完成。如果某任务于第P分钟开始,持续时间为T分钟,则该任务将在第P+T-原创 2010-11-13 09:19:00 · 1718 阅读 · 0 评论