2014---多校训练2(ZCC Loves Codefires)
ZCC Loves Codefires
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 790 Accepted Submission(s): 420
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
2014 Multi-University Training Contest 2
代码:
1 #include<cstdio>
2 #include<iostream>
3 #include<algorithm>
4 using namespace std;
5 struct node{
6 int e,t;
7 bool operator < (const node a) const{
8 return e*a.t>a.e*t;
9 }
10 }map[100005];
11 int main(){
12 int n,i;
13 __int64 tat,ans;
14 while(scanf("%d",&n)!=EOF){
15 for(i=0;i<n;i++)
16 scanf("%d",&map[i].t);
17 for(i=0;i<n;i++)
18 scanf("%d",&map[i].e);
19 sort(map,map+n);
20 for(ans=tat=i=0;i<n;i++){
21 tat+=map[i].t;
22 ans+=tat*map[i].e;
23 }
24 printf("%I64dn",ans);
25 }
26 return 0;
27 }
- WP、Win10开发或者WPF开发时绘制自定义窗体~例如:一个手机
- 【Java学习笔记之八】JavaBean中布尔类型使用注意事项
- BZOJ 1597: [Usaco2008 Mar]土地购买【斜率优化+凸包维护】
- BZOJ 1046: [HAOI2007]上升序列【贪心+二分状态+dp+递归】
- 【Java学习笔记之九】java二维数组及其多维数组的内存应用拓展延伸
- BZOJ 1293: [SCOI2009]生日礼物【单调队列】
- Javascript缓存投毒学习与实战
- 【Java学习笔记之十】Java中循环语句foreach使用总结及foreach写法失效的问题
- Codeforces 839B Game of the Rows【贪心】
- Codeforces 839A Arya and Bran【暴力】
- 【Java学习笔记之十一】Java中常用的8大排序算法详解总结
- 浅谈zip格式处理逻辑漏洞
- C/C++中peek函数的原理及应用
- 洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He…【字符串+模拟】
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Three.js教程(4):相机
- 使用GithubActions自动部署应用到自己的服务器(ECS)
- Nuxt项目给script标签添加crossorigin属性
- Canvas系列(12):动画高级
- Canvas系列(13):实战--星空连线图
- VSCode支持Vue自动保存格式化的配置
- 构造方法或new返回该对象
- 使用Node在浏览器打开某个网页
- 快应用初探--把个人博客封装成快应用
- 10分钟开发一个npm全局依赖包(上)
- 10分钟开发一个npm全局依赖包(下)
- Canvas系列(3):路径与状态
- Canvas系列(4):线条操作
- Canvas系列(6):绘制图片
- Canvas系列(7):形变