hdu2670
来源:互联网 发布:2016全国溺水事故数据 编辑:程序博客网 时间:2024/05/29 18:29
Girl Love Value
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 880 Accepted Submission(s): 510
Now a chance is coming for lots of single boys. The Most beautiful and lovely and intelligent girl in HDU,named Kiki want to choose K single boys to travel Jolmo Lungma. You may ask one girls and K boys is not a interesting thing to K boys. But you may not know Kiki have a lot of friends which all are beautiful girl!!!!. Now you must be sure how wonderful things it is if you be choose by Kiki.
Problem is coming, n single boys want to go to travel with Kiki. But Kiki only choose K from them. Kiki every day will choose one single boy, so after K days the choosing will be end. Each boys have a Love value (Li) to Kiki, and also have a other value (Bi), if one boy can not be choose by Kiki his Love value will decrease Bi every day.
Kiki must choose K boys, so she want the total Love value maximum.
First line give the integer n,K (1<=K<=n<=1000)
Second line give n integer Li (Li <= 100000).
Last line give n integer Bi.(Bi<=1000)
3 310 20 304 5 64 320 30 40 502 7 6 5
47104
AC代码:
#include <ctime>#include <string>#include<cstdio>#include<algorithm>using namespace std;int n,k;struct point{ int a,b;}p[100009];bool cmp(point x,point y){ return x.b>y.b;}int dp[100009][1009];int main(){ while(scanf("%d%d",&n,&k)!=EOF) { for(int i=1;i<=n;i++) scanf("%d",&p[i].a); for(int i=1;i<=n;i++) scanf("%d",&p[i].b); int j=0,ans=0; sort(p+1,p+n+1,cmp); for(int i=0;i<=n;i++) dp[i][0]=0; for(int i=1;i<=n;i++) { for(int j=1;j<=i&&j<=k;j++) dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+(p[i].a-(j-1)*p[i].b)); } printf("%d\n",dp[n][k]); } return 0;}
- hdu2670
- [dp问题] Girl Love Value(dp问题)hdu2670
- c++ primer 读书笔记 之第七章类
- Android单元测试(二):再来谈谈为什么
- 无锁队列的实现
- 快速排序
- Eclipse连接mysql数据库
- hdu2670
- Thymeleaf 之 内置对象、定义变量、URL参数及标签自定义属性
- 四大组件之Activity
- hdu 2795 billboard(线段树)
- ural1108Heritage
- javaSE_8系列博客——Java语言的特性(五)--接口和继承(2)--定义接口
- java文件读写操作
- 递推的矩阵乘法解决练习1
- 使用Struts2关于页面信息国际化(简单的)