2014 (多校)1011 ZCC Loves Codefires

2014 (多校)1011 ZCC Loves Codefires

大家好,又见面了,我是全栈君,祝每个程序员都可以多学几门语言。

自从做了多校,整个人都不好了,老是被高中生就算了,题老是都不懂=-=原谅我是个菜鸟,原谅我智力不行。唯一的水题。

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.

 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
struct node{
    int x,y;
}a[maxn];
int cmp(node l1,node l2)
{
    return l1.x*l2.y<l2.x*l1.y;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
            scanf("%d",&a[i].x);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i].y);
        sort(a,a+n,cmp);
        long long sum=0,s=0;
        for(int i=0;i<n;i++)
        {
            sum+=a[i].x;
            s+=sum*a[i].y;
        }
        printf("%I64d\n",s);
    }
    return 0;
}

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

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

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


相关推荐

  • vim复制粘贴命令

    vim复制粘贴命令1.选定文本块。使用v进入可视模式,移动光标键选定内容。 2.复制的命令是y,即yank(提起),常用的命令如下:   y   在使用v模式选定了某一块的时候,复制选定块到缓冲区用;   yy  复制整行(nyy或者yny,复制n行,n为数字);   y^  复制当前到行头的内容;   y$  复制当前到行尾的内容;   yw  复制一个word(ny…

    2022年9月23日
    0
  • HTML网页设计大一期末考试_酒店网页设计特色

    HTML网页设计大一期末考试_酒店网页设计特色旅游住宿酒店的HTML网页设计14页~学生网页设计与制作期末作业下载~大学生网页设计与制作成品下载~DW旅游网页作业代码下载临近期末,你还在为HTML网页设计结课作业,老师的作业要求感到头大?HTML网页作业无从下手?网页要求的总数量太多?没有合适的模板?等等一系列问题。你想要解决的问题,在这篇博文中基本都能满足你的需求~原始HTML+CSS+JS页面设计,web大学生网页设计作业源码,这是一个不错的网页制作,画面精明,非常适合初学者学习使用。作品介绍1.网页作品简介方面:HTML期末

    2022年9月7日
    0
  • vrrp的配置实例_十宗罪案例简介

    vrrp的配置实例_十宗罪案例简介一、背景二、VRRP概念介绍三、实验操作一、背景局域网中的用户终端通常采用配置一个默认网关的形式访问外部网络,如果此时默认网关设备发生故障,将中断所有用户终端的网络访问,这很可能会给用户带来

    2022年8月5日
    0
  • Hive索引

    Hive索引

    2022年1月27日
    47
  • pycharm 设置环境变量_电脑环境变量怎么设置

    pycharm 设置环境变量_电脑环境变量怎么设置今天运行tensorflow的时候,发现在pycharm下,程序无法找到CUDA的libcupti.so文件。而在添加完环境变量:exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH/usr/local/cuda/extras/CUPTI/lib64:后,在命令行可以运行程序。然而,在Pycharm中运行程序,仍无法找到CUDA库文件。经过下午的折腾,终于

    2022年8月28日
    0
  • DataGridView修改HeaderText

    dataGridView_htList为一个DataGridView(ht为HoverTree的缩写)方法一:dataGridView_htList.Columns["HtAddTime&

    2021年12月24日
    49

发表回复

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

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