POJ 1036 Gangsters
来源:互联网 发布:ios免费杂志软件 编辑:程序博客网 时间:2024/06/05 08:24
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 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
26http://www.cppblog.com/cxiaojia/archive/2012/03/29/169388.html
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <cmath>using namespace std;struct note{ int x,y,z;};int cmp(note a,note b){ return a.x<b.x;}int f[3005];int main (){ int n,m,t,ans; note a[3005]; while(~scanf("%d%d%d",&n,&m,&t)) { memset(f,0,sizeof(f)); a[0].x=0; a[0].y=0; a[0].z=0; for(int i=1;i<=n;i++) cin >> a[i].x; for(int i=1;i<=n;i++) cin >> a[i].y; for(int i=1;i<=n;i++) cin >> a[i].z; sort(a+1,a+n+1,cmp); int ans=0; for(int i=1;i<=n;i++) { for(int j=i-1;j>=0;j--) if(f[j]>=a[j].y) if(a[i].x-a[j].x>=abs(a[i].z-a[j].z)) f[i]=max(f[i],f[j]+a[i].y); ans=max(ans,f[i]); } cout<< ans <<endl; } return 0;}
0 0
- poj 1036 Gangsters
- poj 1036 Gangsters
- poj 1036 Gangsters
- POJ 1036 Gangsters
- POJ 1036 Gangsters
- POJ 1036 Gangsters (DP)
- POJ 1036 Gangsters
- POJ 1036 Gangsters
- POJ 1036 Gangsters 题解
- POJ 1036 Gangsters
- poj 1036 Gangsters lis
- POJ 1036 Gangsters 笔记
- POJ 1036 Gangsters
- POJ 1036 Gangsters DP 多解
- poj 1036 Gangsters(DP)
- poj 1036 Gangsters (简单dp)
- POJ 1036 Gangsters 水dp。。
- POJ 1036 Gangsters(DP)
- 使用Unity3D开发项目的一点经验
- eclips环境配置
- Android UI整理
- 用C#连接SqlServer8 r2
- 友元不解1
- POJ 1036 Gangsters
- Antlr的行为规则和属性作用域 Rule Actions Attribute Scopes
- js中判断是否为空
- dojo小例子(6)页面打开后,请求数据,把反馈数据回填页面
- 在java中如何跳出当前的多重循环
- C#面向过程集锦
- 454 .sff剪切并转fasta 或 fastq
- Unique Path II
- Eclipse搭建SSH(Struts2+Spring3+Hibernate3)实践