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
150HintMemset137 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 ...
随机推荐
- ACM_Ruin of Titanic(简单贪心)
Ruin of Titanic Time Limit: 2000/1000ms (Java/Others) Problem Description: 看完Titanic后,小G做了一个梦.梦见当泰坦尼 ...
- 题解报告:hdu 1272 小希的迷宫
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272 Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem ...
- 【IOS网络编程】socket编程 - Asyncsocket
Phone的标准推荐是CFNetwork 库编程,其封装好的开源库是 cocoa AsyncSocket库,用它来简化CFNetwork的调用,它提供了异步操作 主要特性有: 队列的非阻塞的读和写,而 ...
- lua_string_pattern
两大特点: 1. string库中所有的字符索引从前往后是1,2,...;从后往前是-1,-2,... 2. string库中所有的function都不会直接操作字符串,而是返回一个新的字符串. 库函 ...
- python--9、进程池
concurrent.futures模块 进程池中的进程是固定的,若是池中有任务结束后,等待的任务进来后由空闲的进程来处理. 导入方法三连发: from 标题的模块 import 如下:Process ...
- JS——旋转木马
1.opacity和zIndex的综合运用 2.样式的数组的替换:向右边滑动---删除样式数组第一位并在数组最后添加:向左边滑动---删除样式数组最后一位并在数组前添加 3.开闭原则,只有当回调函数执 ...
- vim之补全1(完全个人定制版)
关于vim的补全最初的感觉是蛋疼, 真正的蛋疼! 由于在接触linux之前曾经在windows下面学过一段时间软件开发, 那时使用的是vs2010, 现在看来虽然vs启动相当的慢, 编辑器的定制和配置 ...
- PHP 之二位数组根据某个字段排序封装
/** * @param $array * @param $keys * @param string $sort * @return array */ function arraySort($arra ...
- Sping——使用注解创建切面
为讲解例子,我们首先定义一个Performance接口: package aoptest; public interface Performance { public void perform(); ...
- react typescript 父组件调用子组件
//父组件import * as React from 'react'import { Input } from 'antd'const Search = Input.Searchimport &qu ...