题目链接: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. SVN权限解析规则详解(转)

    首先创建一个版本库后,会生成最初的目录结构和基本的配置文件,本文主要分析“authz”文件的内容:我们先抛开alias和groups不谈,将重点放在路径的权限配置上. 一. 权限格式 svn权限的基本 ...

  2. VC 中与字符串相关的宏 _T、TEXT,_TEXT、L 的作用(简单明了)

    一. 在字符串前加一个L作用:    如  L"我的字符串"    表示将ANSI字符串转换成unicode的字符串,就是每个字符占用两个字节.   strlen("as ...

  3. java OOP及相关基础知识汇总(转)

    OOP 对象有三个要素 behavior 接口是怎样的,有什么方法/field可以用? state 调用方法的时候,对象会有什么反应? 只有通过调用方法才能改变一个对象的state identity ...

  4. exe解析

    IMAGE_DOS_HEADER      size   0x40 e_lfanew                           0xe0 当中有0xA0的间隔数据. IMAGE_NT_HEA ...

  5. thinkPHP 模板的使用技巧(十三)

    原文:thinkPHP 模板的使用技巧(十三) 模板的使用技巧:页面跳转 .模板包含.模板渲染.模板的继承 页面跳转 <a href='__URL__/index'>我要跳转到首页面,用这 ...

  6. Linux实现字符设备驱动的基础步骤

    Linux应用层想要操作kernel层的API,比方想操作相关GPIO或寄存器,能够通过写一个字符设备驱动来实现. 1.先在rootfs中的 /dev/ 下生成一个字符设备.注意主设备号 和 从设备号 ...

  7. 算法起步之动态规划LCS

    原文:算法起步之动态规划LCS 前一篇文章我们了解了什么是动态规划问题,这里我们再来看动态规划另一个经典问题,最长公共子序列问题(LCS),什么是子序列,我们定义:一个给定序列将其中的0个或者多个元素 ...

  8. hdu 3309 Roll The Cube ( bfs )

    Roll The Cube Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  9. CF 519E(树上倍增求lca)

    传送门:A and B and Lecture Rooms 题意:给定一棵树,每次询问到达点u,v距离相等的点有多少个. 分析:按情况考虑: 1.abs(deep[u]-deep[v])%2==1时, ...

  10. 架设FLASH视频流server心得

    什么样的情况下才使用FMS?有下面几种情形的时候,你可能须要用到FMS 1.须要通过Flash Player 播放视频,而视频是以流的方式,而不是http渐进式下载的方式进行播放的时候.渐进式下载就是 ...