2 shunfurh shunfurh 于 2017.01.03 17:01 提问

Gangsters
it

Description

N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness expressed by the integers in the range [0, K]. The state of openness can change by one in one unit of time; i.e. it either opens by one, closes by one or remains the same. At the initial moment of time the door is closed (state 0). The i-th gangster enters the restaurant only if the door is opened specially for him, i.e. when the state of openness coincides with his stoutness Si. If at the moment of time when the gangster comes to the restaurant the state of openness is not equal to his stoutness, then the gangster goes away and never returns.
The restaurant works in the interval of time [0, T].
The goal is to gather the gangsters with the maximal total prosperity in the restaurant by opening and closing the door appropriately.
Input

?The first line of the input file contains the values N, K, and T, separated by spaces. (1 <= N <= 100 ,1 <= K <= 100 ,0 <= T <= 30000 )
?The second line of the input file contains the moments of time when gangsters come to the restaurant T1, T2, ..., TN, separated by spaces. ( 0 <= Ti <= T for i = 1, 2, ..., N)
?The third line of the input file contains the values of the prosperity of gangsters P1, P2, ..., PN, separated by spaces. ( 0 <= Pi <= 300 for i = 1, 2, ..., N)
?The forth line of the input file contains the values of the stoutness of gangsters S1, S2, ..., SN, separated by spaces. ( 1 <= Si <= K for i = 1, 2, ..., N)
All values in the input file are integers.
Output

Print to the output file the single integer ?the maximal sum of prosperity of gangsters in the restaurant. In case when no gangster can enter the restaurant the output should be 0.
Sample Input

4 10 20
10 16 8 16
10 11 15 1
10 7 1 8
Sample Output

26

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.09 23:53
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
UVA 672 - Gangsters(dp)
Gangsters  N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness expressed by th
Economic Gangsters
Chapter One Fighting For Economic Development 1 Chapter Two Suharto, Inc. 22 Chapter Three The Smuggling Gap 53 Chapter Four Nature or Nurture? Understanding the Culture of Corruption 76 Chapter Five No Water, No Peace 111 Chapter Six Death by a Thousand Small Cuts 136 Chapter Seven The Road Back From War 159 Chapter Eight Learning to Fight Economic Gangsters 186 Epilogue Doing Better This Time 207
POJ1036 Gangsters
微微发亮的传送门 这道题是一到比较水的DP,其实看看就能猜到状态转移方程,因为已经是一个定型。 dp[i][j]表示的是当第i分钟门的打开程度为j的时候获得的最大繁荣度,很容易推知方程dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1], dp[i - 1][j + 1]) + w,w表示的是这一分钟能够获得的繁荣度,注意处理边界情况。 最开始我按照常规
poj1036 Gangsters
题意:N个歹徒去一个餐馆,旅馆门有k个打开程度(每个打开程度为门的一个状态),每个歹徒拥有自己的肥胖度(两个歹徒的肥胖度可能相同)和繁荣度(prosperity),歹徒在i 时刻到餐厅来(两个歹徒可能同时来餐馆),若此时刻门的打开程度与歹徒的肥胖度相同,则歹徒就进入餐馆,同时餐馆
POJ 1036 Gangsters
http://poj.org/problem?id=1036 Description N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of o
UVA 672 Gangsters
题意: 一家饭店,有一扇大小会变得门,变化范围为[0,k]。每过一单位时间你可以让门的大小+1,-1,或者不变。客人会在不同的时间来吃饭,但是如果门的大小和他们希望的值不一样,他们就不会进来并且直接消失。吃饭要花钱,现在问饭店最多能赚多少钱。 解法: 设dp[i][j] 为时间i门的大小为j时最多能赚的钱,那么有如下转移: dp[i][j] = max(dp[i-1][j-1], dp[i-1
URAL 1409. Two Gangsters
1409. Two Gangsters Time limit: 1.0 second Memory limit: 64 MB Two gangsters Harry and Larry had a rest at countryside. They decided to spend some time shooting, so they put several beer ca
soj 1679 Gangsters(dp)
@(K ACMer)题意: 有一个店铺,他的门的宽度在[0,k][0, k]可调剂,每个单位时间可以调节一位或者不变.有n个枪手会走来,每个枪手有直接的身体宽度,荣耀度和来的时间.只有当门的宽度恰好等于枪手的宽度的时候他们才会进来.问在[0,T][0, T]的时间内店铺可以进来的最大荣耀度是多少?(门的宽度由你调节) 分析: 这个其实类似一个背包,每来一个人我们要满足或者不满足他,这些人来的顺
poj 1036 Gangsters
题目链接:http://poj.org/problem?id=1036       这道题是用dp[i]记录第i个强盗成功进入的最优值。 #include #include #include #include #include #include #include #include #include #include #include #include using namespace std
poj 1036 Gangsters(DP)
题目链接:点击打开链接