hdu_2670Girl Love Value(dp)

时间:2021-10-29 19:56:00

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2670

Girl Love Value

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 795    Accepted Submission(s): 448

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.

hdu_2670Girl Love Value(dp)

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)
 
Output
Output only one integer about the maximum total Love value Kiki can get by choose K boys.
 
Sample Input
3 3
10 20 30
4 5 6
4 3
20 30 40 50
2 7 6 5
 
Sample Output
47
104
题解: 注意在选的这些个人中,肯定是每日损失最大的先选,所以按照损失从大到小排序,然后就是一个简单的0,1排序了。
dp[i][j] = max(dp[i-1][j],dp[i-1][j-1]+a[i]-b[i]*(j-1);
可以压缩成一维的
代码:
 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = ;
int dp[N];
struct Node{
int a;
int b;
bool operator < (const Node& tm) const{
return b>tm.b;
}
}node[N];
int main()
{
int n,k;
while(~scanf("%d%d",&n,&k))
{
for(int i = ; i < n; i++)
scanf("%d",&node[i].a);
for(int i = ; i < n; i++)
scanf("%d",&node[i].b);
memset(dp,,sizeof(dp));
sort(node,node+n);
for(int i = ; i < n; i++)
{
for(int j = k; j > ; j--)
{
dp[j] = max(dp[j],dp[j-]+node[i].a-node[i].b*(j-));
}
}
printf("%d\n",dp[k]);
}
return ;
}

hdu_2670Girl Love Value(dp)的更多相关文章

  1. BZOJ 1911&colon; &lbrack;Apio2010&rsqb;特别行动队 &lbrack;斜率优化DP&rsqb;

    1911: [Apio2010]特别行动队 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 4142  Solved: 1964[Submit][Statu ...

  2. 2013 Asia Changsha Regional Contest---Josephina and RPG&lpar;DP&rpar;

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...

  3. AEAI DP V3&period;7&period;0 发布,开源综合应用开发平台

    1  升级说明 AEAI DP 3.7版本是AEAI DP一个里程碑版本,基于JDK1.7开发,在本版本中新增支持Rest服务开发机制(默认支持WebService服务开发机制),且支持WS服务.RS ...

  4. AEAI DP V3&period;6&period;0 升级说明,开源综合应用开发平台

    AEAI DP综合应用开发平台是一款扩展开发工具,专门用于开发MIS类的Java Web应用,本次发版的AEAI DP_v3.6.0版本为AEAI DP _v3.5.0版本的升级版本,该产品现已开源并 ...

  5. BZOJ 1597&colon; &lbrack;Usaco2008 Mar&rsqb;土地购买 &lbrack;斜率优化DP&rsqb;

    1597: [Usaco2008 Mar]土地购买 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4026  Solved: 1473[Submit] ...

  6. &lbrack;斜率优化DP&rsqb;【学习笔记】【更新中】

    参考资料: 1.元旦集训的课件已经很好了 http://files.cnblogs.com/files/candy99/dp.pdf 2.http://www.cnblogs.com/MashiroS ...

  7. BZOJ 1010&colon; &lbrack;HNOI2008&rsqb;玩具装箱toy &lbrack;DP 斜率优化&rsqb;

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9812  Solved: 3978[Submit][St ...

  8. px、dp和sp,这些单位有什么区别?

    DP 这个是最常用但也最难理解的尺寸单位.它与“像素密度”密切相关,所以 首先我们解释一下什么是像素密度.假设有一部手机,屏幕的物理尺寸为1.5英寸x2英寸,屏幕分辨率为240x320,则我们可以计算 ...

  9. android px转换为dip&sol;dp

    /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public int dipTopx(Context context, float dpValue) { final floa ...

随机推荐

  1. Android系统自带APP分析——短信app

    Android操作系统本身就是一个巨大的开源软件仓库,熟悉它既可以了解到Android系统的设计框架,也可以获得高效的应用程序编写方式.本文所分析的源码来自于Google官方的AOSP源码4.0.1_ ...

  2. JavaScript中的加法运算

    <head runat="server"> <title>JavaScript实现加法计算器</title> <script type=& ...

  3. 在DataList、Repeater的HeaderTemplate和FooterTemplate模板中寻找控件FindControl

    [程序代码] <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> ...

  4. IMAP收邮件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. 简单的访客IP获取类-IPHelper&period;cs

    public class IPHelper { public static string GetVisitorsIPAddress() { string result = String.Empty; ...

  6. oc 快排算法

    直接复制粘贴就可以用了 - (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *M_arr = [[NSMutableArray allo ...

  7. 在Web界面中实现Excel数据大量导入的处理方式

    在早期Bootstrap框架介绍中,我的随笔<结合bootstrap fileinput插件和Bootstrap-table表格插件,实现文件上传.预览.提交的导入Excel数据操作流程> ...

  8. Nginx系列0:Nginx学习历程

    Nginx学习历程 一.初识Nginx 1.Nginx适用于哪些场景 (1)静态资源服务 通过本地文件系统提供服务 (2)反向代理服务 Nginx的强大性能 缓存 负载均衡 (3)API服务 Open ...

  9. 使用 tabindex 改变Tab 键顺序

    使用 tabindex原文 https://developers.google.cn/web/fundamentals/accessibility/focus/using-tabindex 在表单上使 ...

  10. Mysql优化要点

    优化MySQL Mysql优化要点 慢查询 Explain mysql慢查询 注意事项 SELECT语句务必指明字段名称 SELECT *增加很多不必要的消耗(cpu.io.内存.网络带宽):增加了使 ...