HDU 2670 Girl Love Value
来源:互联网 发布:反编译软件 编辑:程序博客网 时间:2024/06/06 14:24
Girl Love Value
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 743 Accepted Submission(s): 412
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
Author
yifenfei
Source
HDU女生专场公开赛——谁说女子不如男
题意:有n个男生追一个女生,每个男生有一个相应的爱慕值Vx(i),给定一个天数m,每天这个女生只能找一个女生,并且得到这个男生的爱慕值。每过一天,每个男生的爱慕值就会减少相应的 Vy(i);问女生如何选择,m天之后,才能得到最大的爱慕值。
咋看一眼是贪心的题目,每次都先选爱慕值最大的,和这个女生约会。。可是后来发现问题,要是天数很多的话,有些男生的爱慕值减少的很快,这样贪心就不好处理了,因为不清楚m天后的爱慕值,也不知道是先选减得多的还是爱慕值大的。
其实是01背包的变形。
讨论选不选第n-1个人。
假如选,爱慕值为dp[j]。假如不选,爱慕值为dp[j-1]+这个男生的爱慕值-(每天减少的爱慕值*天数)。
上代码
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include <math.h>using namespace std;struct node{ int value,ans;};bool cmp(node a,node b){ return a.ans>b.ans;}/*---------------------------------------------*/ //下面注释部分为贪心的错误解法。/*---------------------------------------------*/int main(){ node f[1005]; int dp[1005]; int n,day,i,j,love,Max; while(cin>>n>>day) { memset(dp,0,sizeof(dp)); // love=0; for(i=0; i<n; i++) cin>>f[i].value; for(i=0; i<n; i++) cin>>f[i].ans; sort(f,f+n,cmp); /* while(day--) { love+=f[0].value; f[0].value=-100005; break; } for(i=0; i<n; i++) { if(f[i].value!=-100005) f[i].value-=f[i].ans; } sort(f,f+n,cmp); } */ for(i=0; i<n; i++) for(j=day; j>0; j--) { dp[j]=max(dp[j],dp[j-1]+f[i].value-f[i].ans*(j-1)); } // cout<<love<<endl; cout<<dp[day]<<endl; } return 0;}
0 0
- HDU 2670 Girl Love Value
- HDU 2670 Girl Love Value 动态规划
- 【HDU 2670】【背包】Girl Love Value
- hdu 2670 Girl Love Value(刚好装满的01背包)
- HDOJ 题目2670 Girl Love Value(01背包)
- [dp问题] Girl Love Value(dp问题)hdu2670
- a girl i love
- hdojGirl Love Value 2670 (01背包)
- A girl’s love from cc98侵删
- 紫荆花开之say love to the girl you love
- WUST OJ 1421 we love girl(贪心或DP)
- hdoj2670Girl Love Value【01背包】
- HDU - 4324 Triangle LOVE
- hdu 4324 - Triangle LOVE
- hdu 4324 Triangle LOVE
- HDU 4324 Triangle LOVE
- hdu 4324 Triangle LOVE
- HDU 5082 Love
- 133 - The Dole Queue
- 【PLSQL】package包的使用
- hdu1568
- sqlite语句
- 二哥学算法之排序
- HDU 2670 Girl Love Value
- Haproxy配置文件详解
- 求10个数中最大值
- oc_study17--property的简便方式
- 黑马程序员_JAVA中IO流-字节流与字符流比较与转换
- 156 - Ananagrams
- 统治世界的十大算法
- OA的学习--第二天的内容--日志和BaseDao
- 一道水题 【strtok分解字符串】