POJ 1036 Gangsters
来源:互联网 发布:企业名录软件代理 编辑:程序博客网 时间:2024/06/05 08:28
Gangsters
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 11992 Accepted: 3352
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
#include <stdio.h>#include <string.h>#include <algorithm>#define N 105using namespace std;typedef struct{ int t,p,s;}Node;Node a[N];int dp[N];int cmp(Node x,Node y){ return x.t>y.t;}int main(){ int n,K,T; while(scanf("%d%d%d",&n,&K,&T)>0){ memset(dp,0,sizeof(dp)); for(int i=0;i<n;i++) scanf("%d",&a[i].t); for(int i=0;i<n;i++) scanf("%d",&a[i].p); for(int i=0;i<n;i++) scanf("%d",&a[i].s); sort(a,a+n,cmp); for(int i=0;i<n;i++){ if(a[i].s>a[i].t) continue; dp[i]=a[i].p; for(int j=0;j<i;j++) if(abs(a[j].t-a[i].t)>=abs(a[j].s-a[i].s)) dp[i]=max(dp[i],dp[j]+a[i].p); } int sum=0; for(int i=0;i<n;i++) sum=max(sum,dp[i]); printf("%d\n",sum); } return 0;}
DP
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)
- 自定义圆角ImageView方案1,去锯齿
- 初识Linux服务器。
- Android draw canvas save restore saveLayer 学习
- 学习HanNLP2015年12月4日 16:24:53
- iOS开发——warning: directory not found for option ' '
- POJ 1036 Gangsters
- MySQL内存使用-线程独享
- 分布式系统的事务处理
- android工程生成第三方jar包
- 如何安装本地jar包到maven库
- 算法学习之求数列和
- Dynamics CRM 为Visual Studio 2015安装CRM Developer Toolkit
- Ubuntu ROS Arduino Gazebo学习镜像iso说明(indigo版)
- Mysql几种索引类型的区别及适用情况(转载)