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

----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋http://user.qzone.qq.com/593830943/main

----------------------------------------------------------------------------------------------------------------------------------------------------------

ZCC Loves Codefires

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 26    Accepted Submission(s): 17
Problem Description
Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called "Memset137".

It was on Codefires(CF), an online competitive programming site, that ZCC knew Memset137, and immediately became his fan.

But why?

Because Memset137 can solve all problem in rounds, without unsuccessful submissions; his estimation of time to solve certain problem is so accurate, that he can surely get an Accepted the second he has predicted. He soon became IGM, the best title of Codefires.
Besides, he is famous for his coding speed and the achievement in the field of Data Structures.

After become IGM, Memset137 has a new goal: He wants his score in CF rounds to be as large as possible.

What is score? In Codefires, every problem has 2 attributes, let's call them Ki and Bi(Ki, Bi>0). if Memset137 solves the problem at Ti-th second, he gained Bi-Ki*Ti score. It's guaranteed Bi-Ki*Ti is always positive during the round time.

Now that Memset137 can solve every problem, in this problem, Bi is of no concern. Please write a program to calculate the minimal score he will lose.(that is, the sum of Ki*Ti).
 
Input
The first line contains an integer N(1≤N≤10^5), the number of problem in the round.

The second line contains N integers Ei(1≤Ei≤10^4), the time(second) to solve the i-th problem.

The last line contains N integers Ki(1≤Ki≤10^4), as was described.
 
Output
One integer L, the minimal score he will lose.
Sample Input
3
10 10 20
1 2 3
 
Sample Output
150
Hint
Memset137 takes the first 10 seconds to solve problem B, then solves problem C at the end of the 30th second. Memset137 gets AK at the end of the 40th second.
L = 10 * 2 + (10+20) * 3 + (10+20+10) * 1 = 150.

Author
镇海中学
 
Source
 
Recommend
We have carefully selected several similar problems for you:  4881 4880 4879 4878 4877 


思路:先解决每分钟失去的分数比率大的;

代码例如以下:

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
struct st
{
int t, k;
double f;
}ti[100017];
bool cmp(st a, st b)
{
return a.f > b.f;
}
int main()
{
int N;
int i, j;
while(~scanf("%d",&N))
{
for(i = 0; i < N; i++)
{
scanf("%d",&ti[i].t);
}
for(i = 0; i < N; i++)
{
scanf("%d",&ti[i].k);
ti[i].f = (ti[i].k*1.0)/ti[i].t;//每分钟失去的分数
}
sort(ti,ti+N,cmp);
__int64 sum = 0;
__int64 tt = 0;
for(i = 0; i < N; i++)
{
tt+=ti[i].t;
sum+=tt*ti[i].k;
}
printf("%I64d\n",sum);
}
return 0;
}

hdu 4882 ZCC Loves Codefires(数学题+贪心)的更多相关文章

  1. HDU 4882 ZCC Loves Codefires (贪心)

    ZCC Loves Codefires 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/B Description Though ...

  2. 2014多校第二场1011 || HDU 4882 ZCC Loves Codefires (贪心)

    题目链接 题意 : 给出n个问题,每个问题有两个参数,一个ei(所要耗费的时间),一个ki(能得到的score).每道问题需要耗费:(当前耗费的时间)*ki,问怎样组合问题的处理顺序可以使得耗费达到最 ...

  3. hdu 4882 ZCC Loves Codefires(贪心)

    # include<stdio.h> # include <algorithm> # include <string.h> using namespace std; ...

  4. HDU 4882 ZCC Loves Codefires(贪心)

     ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. hdu 4882 ZCC Loves Codefires (贪心 推导)

    题目链接 做题的时候凑的规律,其实可以 用式子推一下的. 题意:n对数,每对数有e,k, 按照题目的要求(可以看下面的Hint就明白了)求最小的值. 分析:假设现在总的是sum, 有两个e1 k1 e ...

  6. BZOJ 3850: ZCC Loves Codefires【贪心】

    Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called "Memset137". It wa ...

  7. HDU-4882 ZCC Loves Codefires

    http://acm.hdu.edu.cn/showproblem.php?pid=4882 ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Ot ...

  8. 2014---多校训练2(ZCC Loves Codefires)

    ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  9. HDU 4876 ZCC loves cards(暴力剪枝)

    HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...

随机推荐

  1. [置顶] 自己动手写Web容器之TomJetty之六:动态页面引入

    传送门 ☞ 1.Web服务内功经脉 传送门 ☞ 2.让服务动起来 传送门 ☞ 3.掀起请求盖头来 传送门 ☞ 4.静态页面起步 传送门 ☞ 5.包装请求参数 在上一节,我们已经完成了TomJetty服 ...

  2. hdu 4706 Children's Day 2013年ICPC热身赛A题 模拟

    题意:按字母顺序排列成n型,简单的模拟题. 当字母排到z时从a开始重新排起. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: ...

  3. HTML中Id和Name的区别

    源地址:http://www.cnblogs.com/laodai/articles/2244215.html 在html中:name指的是用户名称,ID指的是用户注册是系统自动分配给用户的一个序列号 ...

  4. QT5.6,5.7,5.8的新特征以及展望

    https://wiki.qt.io/New_Features_in_Qt_5.6 (跨平台High-DPI,改进WebEngine到45,支持WIN 10,Canvas3D,3D) https:// ...

  5. Dnasp计算LD

    Dnasp计算LD Table of Contents 1 Dnasp 计算LD 1 Dnasp 计算LD Dnasp有很多的功能,现在主要来记录其计算LD的功能. 首先File——然后打开data— ...

  6. wamp环境中mysql更改root密码

    集成的wamp环境命令不好使,在phpmyadmin中更改密码 权限——root用户修改,执行 然后,你会发现你不能用phpmyadmin登陆了修改下phpmyadmin里面对应的密码就可以了将php ...

  7. Linux 技巧之 Grub 超实用技巧

    1. 简单介绍 什么是 GRUB?GRUB 全名Grand Unified Boot Loader,它是一个引导装入器 -- 它负责装入内核并引导 Linux 系统.GRUB 还能够引导其他操作系统, ...

  8. 【Cocos2d-X开发学习笔记】第30期:游戏中数据的存储(下)

    本系列学习教程使用的是cocos2d-x-2.1.4(最新版为3.0alpha0-pre) ,PC开发环境Windows7,C++开发环境VS2010 一.对数据进行编解码 在上一期中,我们使用了CC ...

  9. linux LVS DR模式配置

    拓扑图: 测试环境:CentOS 6.5 X86 64位 配置步骤: 1.  安装测试环境 [root@UCS-1 ~]# yum -y install httpd [root@UCS-1 ~]# c ...

  10. 【WinRT】【译】【加工】在 XAML 中制作圆形图片

    原文:[WinRT][译][加工]在 XAML 中制作圆形图片 原文地址:http://timheuer.com/blog/archive/2015/05/06/making-circular-ima ...