HDU-4882 ZCC Loves Codefires
http://acm.hdu.edu.cn/showproblem.php?pid=4882
ZCC Loves Codefires
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 97 Accepted Submission(s): 55
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.
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<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
int x,y;
}a[100005];
bool cmp(node b,node c)
{
return b.x*c.y<=b.y*c.x;
}
int main()
{
int n,i;
__int64 ans,cnt;
while(~scanf("%d",&n))
{
for(i=0;i<n;i++)
scanf("%d",&a[i].x);
for(i=0;i<n;i++)
scanf("%d",&a[i].y);
sort(a,a+n,cmp);
ans=cnt=0;
for(i=0;i<n;i++)
{
cnt+=a[i].x;
ans+=cnt*a[i].y;
}
printf("%I64d\n",ans);
}
return 0;
}
HDU-4882 ZCC Loves Codefires的更多相关文章
- hdu 4882 ZCC Loves Codefires(数学题+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...
- 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(贪心)
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- 2014多校第二场1011 || HDU 4882 ZCC Loves Codefires (贪心)
题目链接 题意 : 给出n个问题,每个问题有两个参数,一个ei(所要耗费的时间),一个ki(能得到的score).每道问题需要耗费:(当前耗费的时间)*ki,问怎样组合问题的处理顺序可以使得耗费达到最 ...
- hdu 4882 ZCC Loves Codefires (贪心 推导)
题目链接 做题的时候凑的规律,其实可以 用式子推一下的. 题意:n对数,每对数有e,k, 按照题目的要求(可以看下面的Hint就明白了)求最小的值. 分析:假设现在总的是sum, 有两个e1 k1 e ...
- hdu 4882 ZCC Loves Codefires(贪心)
# include<stdio.h> # include <algorithm> # include <string.h> using namespace std; ...
- 2014---多校训练2(ZCC Loves Codefires)
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU 4876 ZCC loves cards(暴力剪枝)
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...
- hdu 4873 ZCC Loves Intersection(大数+概率)
pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...
随机推荐
- 使用预处理PreparedStatement执行Sql语句
/** * 使用预处理的方式执行Sql * @param sql Sql语句 * @param obj 变量值数组 * @return 查询结果 * @throws SQLException */ p ...
- CF 353C Find Maximum #205 (Div. 2)
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ]; ] ...
- Qt4升级Qt5注意问题
Qt4升级Qt5注意问题 Qt4过渡到Qt5的项目一开始就受阻,记录一下遇到的下面的问题 --->编译遇到类似错误: error: QCalendarWidget: No such file o ...
- ios开发图片点击放大
图片点击放大,再次点击返回原视图.完美封装,一个类一句代码即可调用.IOS完美实现 创建了一个专门用于放大图片的类,以下为.h文件 #import <Foundation/Foundation. ...
- 31. Next Permutation
题目: Implement next permutation, which rearranges numbers into the lexicographically next greater per ...
- C++:this指针
this指针 this关键字:表示本类中的对象成员,可以通过this指针访问当前类的成员//举例 //例 3.18 隐藏this指针的引例 #include<iostream> using ...
- 遍历并remove HashMap中的元素时,遇到ConcurrentModificationException
遍历并remove HashMap中的元素时,遇到ConcurrentModificationException for (Map.Entry<ImageView, UserConcise> ...
- hadoop-0.23.9安装以及第一个mapreduce测试程序
hadoop是一个能够对大量数据进行分布式处理的软件框架.它实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS.HDFS有着高容错性的特点,并且设计 ...
- linux内核链表分析
一.常用的链表和内核链表的区别 1.1 常规链表结构 通常链表数据结构至少应包含两个域:数据域和指针域,数据域用于存储数据,指针域用于建立与下一个节点的联系.按照指针域的组织以及各个节 ...
- Pig简单入门
pig是hadoop客户端,使用类似于SQL的面向数据流的语言pig latin,这个语言可以完成排序,过滤,求和,关联等操作,可以支持自定义函数.Pig自动把pig latin 映射为Map-Red ...