2014—多校训练2(ZCC Loves Codefires)

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---多校训练2(ZCC Loves Codefires)
2014---多校训练2(ZCC Loves Codefires)

 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("%I64d\n",ans);
25     }
26   return 0;
27 }

View Code

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109739.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • tar 命令详解「建议收藏」

    tar 命令详解「建议收藏」tar命令[root@linux~]#tar[-cxtzjvfpPN]文件与目录….参数:-c:建立一个压缩文件的参数指令(create的意思);-x:解开一个压缩文件的参数指令!-t:查看tarfile里面的文件!-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能

    2022年6月5日
  • 逻辑漏洞之密码找回漏洞(semcms)「建议收藏」

    逻辑漏洞之密码找回漏洞(semcms)「建议收藏」目录什么是密码找回漏洞一般流程可能产生该漏洞的情况脑洞图1.用户凭证暴力破解2.返回凭证3.邮箱弱token4.用户凭证有效性5.重新绑定6.服务器验证7.用户身份验证8.找回步骤9.本地验证10.注入11.Token生成12.注册覆盖13.session覆盖演示暴破验证码找回密码更改id号修改admin密码靶场cms下载什么是密码找回漏洞利用漏洞修改他人帐号密码,甚至修改管理员的密码。一般流程1首先尝试正常找回密码流程,选择不同的找回方式,记录所有数据包2分析数据包,找到敏感部分3

    2022年4月30日
  • Arduino连接LCD1602显示屏

    Arduino连接LCD1602显示屏LCD1602液晶屏带I2C接口使用I2C接口,省IO口,只需要4条线即可。通过背光灯,和可调节对比度(就是背面蓝色那块可以旋转的调)自从1.6.6版本的IDE出来后,不断有反应LCD1602IIC液晶显示不正常,打印一字符串,却只显示第一个字符!最初解决办法换低版本IDE,就可以解决该问题!现在问题找出来了,只需要更改LiquidCrystal_I2C.cpp文件中的一个语…

    2022年7月16日
  • Redis布隆过滤器原理及应用场景「建议收藏」

    Redis布隆过滤器原理及应用场景「建议收藏」1、布隆过滤器是什么?(判断某个key一定不存在)本质上布隆过滤器是一种数据结构,比较巧妙的概率型数据结构特点是高效地插入和查询,可以用来告诉你“某样东西一定不存在或者可能存在”。相比于传统的List、Set、Map等数据结构,它更高效、占用空间更少,但是缺点是其返回的结果是概率性的,而不是确切的。使用:1.布隆过滤器在NoSQL数据库领域中应用的非常广泛2….

    2022年9月28日
  • android studio接口调用_android studio jdk版本

    android studio接口调用_android studio jdk版本Android做jni的时候需要根据nativejava类生成对应的.h头文件,然后根据.h头文件写cpp文件。在Androidstudio中可以添加自定义工具,将javah指令添加进去首先我们看下javah的指令格式由此指令我们知道怎么使用javah指令例如有java文件D:\project\Test\app\src\main\java\com\example\test.java编译生成的class文件位于D:\project\Test\app\build\interm.

    2022年9月24日
  • pycharm上传代码到gitlab_可以在gitlab里查看代码

    pycharm上传代码到gitlab_可以在gitlab里查看代码1.Pycharm关联Git安装路径(1)确定自己已经安装git,并且知晓git安装目录,我这里git安装在D盘目录下。(2)打开pycharm—->File——>Settings【点击Test后,出现弹框5,点击OK,此时Pycharm已关联git路径成功。】2.pycharm从gitlab上拉取代码(1)依次点击下图中…

    2022年8月28日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号