
DP
Wangzning_
这个作者很懒,什么都没留下…
展开
-
[CodeForces 859C] Pie Rules
You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which ...原创 2019-04-03 21:35:49 · 279 阅读 · 0 评论 -
HDU - 1260 Tickets
Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as...原创 2019-03-28 19:11:41 · 164 阅读 · 0 评论 -
HDU - 1257 最少拦截系统 最长上升子序列
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统...原创 2019-03-28 19:14:27 · 225 阅读 · 0 评论 -
HDU - 1160 FatMouse's Speed
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...原创 2019-03-28 19:21:20 · 208 阅读 · 0 评论 -
POJ - 1661 Help Jimmy
"Help Jimmy" 是在下图所示的场景上完成的游戏。 场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑...原创 2019-04-02 17:12:25 · 195 阅读 · 0 评论 -
Canonical Coin Systems
题目描述A coin system S is a finite (nonempty) set of distinct positive integers corresponding to coin values, also called denominations, in a real or imagined monetary system. For example, the coin s...原创 2019-04-13 00:07:46 · 427 阅读 · 0 评论 -
Hie with the Pie 状压+最短路
The 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 ...原创 2019-04-22 20:51:00 · 194 阅读 · 0 评论 -
CSU - 1592 石子归并 区间DP
思路:dp[i][j] 表示选i - j 这个区间的最小价值dp[0][0] = 0用前缀和表示来求去这个区间得到的代价dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + sum[j] - sum[i-1]) k 在 [i,j] 中AC代码#include<iostream>#include<algo...原创 2019-04-23 15:01:13 · 159 阅读 · 0 评论 -
POJ - 3254 Corn Fields 状压DP
题意:把奶牛放在1的位置上,且两个奶牛之间不能相邻求出一行当中满足两两不相邻的状态 -> 当前状态 & 当前状态左移一位, 如果结果为零则满足条件,否则不满足 存入st数组例: 101, 1010 | 11, 110将每一行的1,0转成二进制存到一个数里,这里反着处理一下,010表示 第一三草坪可以放牛 存入a数组这样处理可以保证,当st & ...原创 2019-04-24 20:22:19 · 217 阅读 · 0 评论 -
HDU - 1565 方格取数 状压DP
题意:在n*n的格子里 取数 且 取得数两两不相邻,求最大的总和求出一行当中满足两两不相邻的状态->当前状态 & 当前状态左移一位, 如果结果为零则满足条件,否则不满足 存入st数组例: 101, 1010|11, 110然后 dp 处理一下st[j] & st[k] == 0 保证竖直方向不相邻dp[i][j] += dp[i-1]...原创 2019-04-24 20:27:15 · 267 阅读 · 0 评论 -
HDU - 1176 免费馅饼
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...原创 2019-03-28 19:09:46 · 219 阅读 · 0 评论 -
POJ - 3616 Milking Time
Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her nextN(1 ≤N≤ 1,000,000) hours (conveniently labeled 0..N-1) so that she...原创 2019-04-01 20:15:36 · 183 阅读 · 0 评论 -
POJ - 1458 Common Subsequence 动态规划
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...原创 2019-03-30 21:55:43 · 194 阅读 · 0 评论 -
POJ - 2533 Longest Ordered Subsequence
第一种情况,序列只有他自己 dp[i] = 1第二种情况,a[i] > a[j] i>j dp[i] = max(dp[i],dp[j]+1)#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include&l...原创 2019-03-30 21:58:45 · 136 阅读 · 0 评论 -
POJ - 3186 Treats for the Cows
FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given p...原创 2019-03-31 21:02:45 · 146 阅读 · 0 评论 -
HDU - 1078 FatMouse and Cheese 记忆化搜索
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid lo...原创 2019-03-31 21:10:23 · 180 阅读 · 0 评论 -
HDU - 1074 Doing Homework 状压DP
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after th...原创 2019-03-27 19:00:16 · 198 阅读 · 0 评论 -
HDU - 1087 Super Jumping! Jumping! Jumping! 最大上升子序列
思路:第一种情况,序列只有他自己 dp[i] = a[i]第二种情况,a[i] > a[j] i>j dp[i] = max(dp[i],dp[j]+a[i])#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>...原创 2019-03-27 19:04:13 · 207 阅读 · 0 评论 -
HDU - 1114 Piggy-Bank 完全背包
Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple...原创 2019-03-27 19:06:19 · 275 阅读 · 0 评论 -
Codeforces Round #527 (Div. 3) Tree with Maximum Cost
You are given a tree consisting exactly ofnnvertices. Tree is a connected undirected graph withn−1n−1edges. Each vertexvvof this tree has a valueavavassigned to it.Letdist(x,y)dist(x,y)be t...原创 2019-04-06 19:01:30 · 414 阅读 · 0 评论 -
HDU - 2859 Phalanx
Today is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC.A phalanx is a matrix of size n*n, each element is a character (a~z or A~Z), st...原创 2019-04-01 18:12:10 · 265 阅读 · 0 评论 -
UAa 11400 Lighting System Design DP
思路: 按电压进行排序,第i种灯泡可以替换第j种灯泡(i>j),所以可以将第j~i种灯泡全部用第i种灯泡表示,这样我们还需要求一下前缀和来快速得出第j~i种灯泡的数量,用d[i]表示使用前i种灯泡的最小开销,那么转移方程则是,d[i] = min(d[i], d[j] + (sum[i] - sum[j-1]) * c[i] + k[i]); sum[i]是前i种灯泡的数量...原创 2019-07-29 10:53:38 · 209 阅读 · 0 评论