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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • ubuntu dock栏_ubuntu安装sudo命令

    ubuntu dock栏_ubuntu安装sudo命令点击打开链接苹果的MACOS里的dock任务栏让人印象深刻。Dock是苹果公司MacOSX操作系统,及其始祖NeXTSTEP和OPENSTEP操作系统中重要组成部分。在NewtonOS中也有dock概念的一些早期例子。现在在不同操作系统中有很多不同的dock程序。在ubuntu等linux系统中,现在已经可以非常方便的安装使用dock任务栏了,因为很多仿doc

    2025年10月28日
    4
  • android跳转到相册需要权限,Android打开相册获取图片路径[通俗易懂]

    android跳转到相册需要权限,Android打开相册获取图片路径[通俗易懂]一.获得图片路径当我们通过Intent打开相册,获取图片后,在onActivityResult回调中会得到图片的Uri。但是Uri无法直接获得图片的路径。如果你曾经直接操作过android里的数据库的话,应该明白,Uri可以通过ContentResolver获得数据库表里的数据。例如:content://com.android.providers.media.documents/document/…

    2022年9月22日
    6
  • 2021 pycharm激活码_通用破解码

    2021 pycharm激活码_通用破解码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月16日
    54
  • windows-DLL注入「建议收藏」

    windows-DLL注入「建议收藏」DLL注入

    2022年5月17日
    47
  • Aras Innovator: 如何导入项目模板

    Aras Innovator: 如何导入项目模板在Araslabs下载内容中,有两个是ProjectTemplate数据文件,一个是APQP,一个是NPI,下载下来是xml数据。安装方法如下:1.使用nsah.aspx安装2.把模板状态升级到approved3.生成新项目计划时,可选择新增加的模板了

    2025年8月14日
    5
  • Simhash_hartwig

    Simhash_hartwig先贴一张网上的图片:解释一下图片:这里feature可以指一篇文档分词后的某个词,即将文档中的某个词作为一个特征。weight是这个词的权重,这里可以是这个词在这个句子中出现的次数。这里的hash算法就是传统的hash算法,通过调用一个hash函数实现的。simhash是为了计算一篇文档之间的相似度存在的,通过simhash算法可以计算出文档的simhash值,通过各个文档计算出的…

    2022年9月28日
    3

发表回复

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

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