题目链接: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. c 有意思的数组初始化

    c 有意思的数组初始化 #include <stdio.h> int main() { int i = 0; char a[1024]; char a0[10] = {}; char a1 ...

  2. hdu1569find the safest road(floyd变形求最大安全值)

    find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  3. 原型链(__proto__)

    前面详细的解释了new的几个步骤,其中随意带过了一下原型链的概念,如果细读那篇文章,基本对原型也能有所理解. 原型有两个关键属性,一个是 __proto__ 一个是 prototype ,了解了这两个 ...

  4. 使用GDI+绘制的360风格按钮控件(使用CN_DRAWITEM消息重绘,并使用TGPGraphics,TGPPen,TGPImage,TGPBitmap等)good

    将下面的代码拷贝到一个单元中,创建一个包,加入这个单元后安装.使用的时候设置好背景颜色,边框颜色,图标(png格式)相对路径的文件名称.这个控件可以利用PNG图像的颜色透明特性,背景色默认透明度为50 ...

  5. JavaScript 中的继承(读书笔记思维导图)

    继承是 OO 语言中的一个最为人津津乐道的概念.许多 OO 语言都支持两种继承方式:接口继承和实现继承.接口继承只继承方法签名,而实现继承则继承实际的方法.由于函数没有签名,在 ECMAScript ...

  6. VS快捷键教程

    删除或剪切一行(Ctrl + X) 不须要选择不论什么文本, 用来剪切一行, 最经常使用来删除一行.  删除一行也能用 Shift+Delete 格式化整个文档(Ctrl + K, Ctrl + D) ...

  7. Matlab图像彩色转灰色

    Matlab图像彩色转灰色 时间:2014年5月7日星期三 网上找的程序.实现图像彩色转灰色: I1=imread('C:\Users\Yano\Desktop\matlab\test1\4.jpg' ...

  8. Filezilla出现中文乱码

    使用Filezilla client FTP客户端登陆某些FTP站点会出现中文乱码,原因是FTP服务器端编码与filezilla client端编码不一致造成的,解决方法如下:文件-站点管理-选中要登 ...

  9. Deep learning From Image to Sequence

    本文笔记旨在概括地讲deep learning的经典应用.内容太大,分三块. ------------------------------------------------------------- ...

  10. [Java聊天室server]实战之五 读写循环(服务端)

    前言 学习不论什么一个稍有难度的技术,要对其有充分理性的分析,之后果断做出决定---->也就是人们常说的"多谋善断":本系列尽管涉及的是socket相关的知识,但学习之前,更 ...