hdojGirl Love Value 2670 (01背包)
来源:互联网 发布:山东宏业软件 编辑:程序博客网 时间:2024/06/05 22:50
Girl Love Value
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 787 Accepted Submission(s): 442
Problem Description
Love in college is a happy thing but always have so many pity boys or girls can not find it.
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.
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.
Input
The input contains multiple test cases.
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)
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)
Output
Output only one integer about the maximum total Love value Kiki can get by choose K boys.
Sample Input
3 310 20 304 5 64 320 30 40 502 7 6 5
Sample Output
47104/*题意:一个女神要从n个男生中选m个男生,求最大的爱慕值。 给你两个数n,m,分别代表有n个男生,女神要选m个。接下来一行输入n个数表示每个男生对这个女神的初始爱慕值li,再接着一行输入n个数表示每个男生对这个女神的失望值bi(如果今天女神不选他,他对这个女神的爱慕值就会减少bi。。。)思路:知道题意后解题就不是很难了。就是一个单纯的01背包 */#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#define ll long long#define N 1010using namespace std;struct zz{int li;int bi;}q[N];int dp[N];int cmp(zz a,zz b){return a.bi>b.bi;}int main(){int n,m,i,j;while(scanf("%d%d",&n,&m)!=EOF){for(i=0;i<n;i++)scanf("%d",&q[i].li);for(i=0;i<n;i++)scanf("%d",&q[i].bi);sort(q,q+n,cmp);memset(dp,0,sizeof(dp));for(i=0;i<n;i++){for(j=m;j>=1;j--){dp[j]=max(dp[j],dp[j-1]+q[i].li-(j-1)*q[i].bi);}}printf("%d\n",dp[m]);}return 0;}
0 0
- hdojGirl Love Value 2670 (01背包)
- HDOJ 题目2670 Girl Love Value(01背包)
- hdoj2670Girl Love Value【01背包】
- hdu 2670 Girl Love Value(刚好装满的01背包)
- 【HDU 2670】【背包】Girl Love Value
- HDU 2670 Girl Love Value
- HDU 2670 Girl Love Value 动态规划
- HDU 3033 I love sneakers! (01背包+反分组背包)
- HDU 3033 I love sneakers! (DP 01背包+完全背包)
- (分组背包)I love sneakers!(hdu3033)
- HDU3033 I love sneakers!(分组背包)
- HDU3033 I love sneakers!(分组背包)
- I love sneakers!(分组背包变形)
- I love sneakers!(多重背包)
- [dp问题] Girl Love Value(dp问题)hdu2670
- HDU 3033 I love sneakers!(01背包变形)
- hdu 3033 I love sneakers!(分组背包)(微水)
- HDU 3033 I love sneakers!(分组背包变形)
- MYSQL innodb_table_stats表不存在的解决方法
- 工作中接触到的GitHub开源项目
- 多线程编程1 - NSThread
- redis3.0.0 集群安装详细步骤
- angularJS项目开发需要下载安装和配置的环境
- hdojGirl Love Value 2670 (01背包)
- Dubbo应用学习(2)
- Yii安装
- WIFI相关记录
- window.location.hash属性介绍
- SharePoint 2016 开发 工具Preview发布
- 设计模式:观察者模式(有利于代码解耦)
- OpenGL总结
- Ext.form.FieldSet字段集