POJ1036Gangsters题解动态规划DP
来源:互联网 发布:中山大学网络客户端mac 编辑:程序博客网 时间:2024/05/12 01:23
Gangsters
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5690 Accepted: 1605
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.
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.
?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 2010 16 8 1610 11 15 110 7 1 8
Sample Output
26
Source
Northeastern Europe 1998
题意:
有个伸缩门,门的宽度0~K,每个时间可以伸长或缩短1个单位,有N个流氓,他们在T时刻到达,如果这时门的宽度正好与他们的stoutness相等时,便可获得一定的收入p,问最大的收入是多少。
首先按时间排序,两人时间差大于等于stoutness差绝对值,s<=t&&s<=m&&s<T,两个人都可以通过
状态:
d[i]表示第i个人进入的最大收入
状态转移方程:
d[i]=max{d[j]}+a[i].p (0<=j<i)
(a[i].t-a[j].t>=abs(a[i].s-a[j].s)&&a[i].s<=m&&a[j].s<=m)
d[0].t=0
代码:
- POJ1036Gangsters题解动态规划DP
- Bookshelf题解动态规划DP
- POJ2353Ministry题解动态规划DP
- POJ1260Pearls题解动态规划DP
- HDU2845Beans题解动态规划DP
- POJ3356AGTC题解动态规划DP
- POJ1745Divisibility题解动态规划DP
- HDU3449Consumer题解动态规划DP
- POJ2626Chess题解动态规划DP
- POJ1837Balance题解动态规划DP
- POJ3661Running题解动态规划DP
- POJ2229Sumsets题解动态规划DP
- POJ3073Spam题解动态规划DP
- POJ1404I-Keyboard题解动态规划DP
- POJ1463Strategic game题解动态规划DP
- HDU1158Employment Planning题解动态规划DP
- POJ1018Communication System题解动态规划DP
- POJ2264Advanced Fruits题解动态规划DP
- 临界区效率
- Invalidate
- VS 2010无法创建项目提示写入项目文件时出错 没有注册类别
- WebSphere 简介 (1)
- 如何禁止IE缓存,采用Ajax技术数据更新不及时
- POJ1036Gangsters题解动态规划DP
- [WPF] 神奇的DockPanel
- About山寨机
- 用ODBC访问ACCESS模糊查找的问题
- 数据库零散知识
- qsort 线程不安全
- 正整数划分问题(递归优化)
- 光脚丫学LINQ(023):使用SQLMetal将对象模型生成为外部映射文件
- VMware“虚拟机无法锁定内存.....”错误解决方法