HDU4882ZCC Loves Codefires(贪心)
ZCC Loves Codefires
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 823 Accepted Submission(s): 438
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).
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.
3 10 10 20 1 2 3
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.
- #include<stdio.h>
- #include<algorithm>
- using namespace std;
- struct node
- {
- int e,k;
- double f;
- };
- bool cmp(node a,node b)
- {
- return a.f<b.f;
- }
- node a[100005];
- int main()
- {
- int n;
- __int64 sumt=0,ans=0;
- scanf("%d",&n);
- for(int i=0;i<n;i++)
- scanf("%d",&a[i].e);
- for(int i=0;i<n;i++)
- scanf("%d",&a[i].k),a[i].f=1.0*a[i].e/a[i].k;
- sort(a,a+n,cmp);
- for(int i=0;i<n;i++)
- {
- ans+=(sumt+a[i].e)*a[i].k; sumt+=a[i].e;
- }
- printf("%I64d\n",ans);
- }
HDU4882ZCC Loves Codefires(贪心)的更多相关文章
- HDU 4882 ZCC Loves Codefires(贪心)
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- hdu 4882 ZCC Loves Codefires (贪心 推导)
题目链接 做题的时候凑的规律,其实可以 用式子推一下的. 题意:n对数,每对数有e,k, 按照题目的要求(可以看下面的Hint就明白了)求最小的值. 分析:假设现在总的是sum, 有两个e1 k1 e ...
- HDU 4882 ZCC Loves Codefires (贪心)
ZCC Loves Codefires 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/B Description Though ...
- hdu 4882 ZCC Loves Codefires(数学题+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...
- 2014---多校训练2(ZCC Loves Codefires)
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU-4882 ZCC Loves Codefires
http://acm.hdu.edu.cn/showproblem.php?pid=4882 ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Ot ...
- BZOJ 3850: ZCC Loves Codefires【贪心】
Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called "Memset137". It wa ...
- 2014多校第二场1011 || HDU 4882 ZCC Loves Codefires (贪心)
题目链接 题意 : 给出n个问题,每个问题有两个参数,一个ei(所要耗费的时间),一个ki(能得到的score).每道问题需要耗费:(当前耗费的时间)*ki,问怎样组合问题的处理顺序可以使得耗费达到最 ...
- 【贪心】bzoj3850 ZCC Loves Codefires
类似某noip国王游戏. 考虑交换两个题目的顺序,仅会对这两个题目的贡献造成影响. 于是sort,比较时计算两个题目对答案的贡献,较小的放在前面. #include<cstdio> #in ...
随机推荐
- 类型判断----小白讲解typeof,instanceof,Object.prototype.toString.call()
1.typeof只能判断基本类型数据, 例子: typeof 1 // "number" typeof '1' // "string" typeof true ...
- [转]Android ListView的Item高亮显示的办法
本文转自:http://www.cnblogs.com/dyllove98/archive/2013/07/31/3228601.html 在我们使用ListView的时候,经常会遇到某一项(Item ...
- git——merge和rebase的区别
参考http://www.jianshu.com/p/129e721adc6e 我在公司里看到其他同事都使用git pull --rebase拉取远程代码,而我总是用git pull,也有同事和我说过 ...
- 第一次android混淆实战
第一次混淆,主要是因为引用本地第三方jar包的问题.虽然说本地第三方jar包自动避免混淆,但一些本地第三方jar包下的一些包要避免混淆.比如: 文中的com.org 这些包名都要避免混淆. 下面是我用 ...
- C#——计时器的操作
我们可以用Stopwatch类获得程序的运行时间,在优化代码时,可以用此方法来查看优化前后程序所耗费的时间 static void Main(string[] args) { Stopwatch sw ...
- C# WebKitBrowser 设置内容
WebKit.WebKitBrowser kitBrowser = new WebKit.WebKitBrowser(); kitBrowser.Dock = DockStyle.Fill; // k ...
- if判断,while循环,for循环
if判断 if判断其实就是让计算机模拟人的判断 if if 条件: 代码1 代码2 代码3 ... # 代码块(同一缩进级别的代码,例如代码1.代码2和代码3是相同缩进的代码,这三个代码组合在一起就是 ...
- session_start(): open(/var/lib/php/session/sess_tlrp3cpro7gun9uhno8n6futr3, O_RDWR)
在安装一个网站,结果连接上数据库了但是一直报错.下面贴报错内容和图 错误提示 系统:PHP (Linux) 错误类型:WARNING 内容:session_start(): open(/) 错误位置: ...
- mysql动态执行sql批量删除数据
CREATE PROCEDURE `sp_delete_pushmsg_data`() BEGIN ); ); declare l_dutyno int; ; ; ; ; day),'%Y-%m-%d ...
- enote笔记语言(5)——其他
章节:其他 ((主:单词)) 用来醒目地强调这个句子中哪个词语作主语 sentence: ...