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;
}

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • FDD/TDD协同优化

    FDD/TDD协同优化一、 概述目网络面临上行用户体验容量差、深度覆盖不足、热点区域巨大容量需求三重挑战,随着FDD网络大规模部署的日益临近,TD-LTE和LTEFDD融合组网将是4G无线网络未来的演进方向,可以充分激发TDD/FDD两种制式网络的潜力,实现优势互补,最大化资源承载效率,获得最佳网络性能。二、 FDD部署情况XX移动FDD分布于900MHz和1800MHz两个频段,900MHz频段具备频率低、覆…

  • 多模态学习「建议收藏」

    多模态学习「建议收藏」作者:张致远#mermaid-svg-bqinfdlcry278edQ.label{font-family:’trebuchetms’,verdana,arial;font-family:var(–mermaid-font-family);fill:#333;color:#333}#mermaid-svg-bqinfdlcry278edQ.labeltext{fill:#333}#mermaid-svg-bqinfdlcry278edQ.noderect,#mermaid-svg-..

  • OllyDBG 激活成功教程入门教程「建议收藏」

    OllyDBG 激活成功教程入门教程「建议收藏」原链接:https://www.cnblogs.com/ECJTUACM-873284962/p/7653285.html一、OllyDBG的安装与配置OllyDBG版的发布版本是个ZIP压缩包,只要解压到一个目录下,运行OllyDBG.exe就可以了。汉化版的发布版本是个RAR压缩包,同样只需解压到一个目录下运行OllyDBG.exe即可:OllyDBG中各个窗口的功能如上图。简单解释一下各个窗口的功能,更详细的内容可以参考TT小组翻译的中文帮助:反汇编窗口:显示被调试

  • 正確使用 SetCapture ReleaseCapture [譯]「建议收藏」

    正確使用 SetCapture ReleaseCapture [譯]「建议收藏」本文描述瞭如何正確處理自定義窗口和控件中的鼠標捕獲操作。原文鏈接: http://www.codeproject.com/Tips/127813/Using-SetCapture…correctly.aspx原作者: pasztorpisti轉載請註明出處:http://www.imoldman.com/2010/11/30/using-setcaptu…ture-corre

  • PostMan的安装和使用教程[通俗易懂]

    PostMan的安装和使用教程[通俗易懂]postman的下载官网:https://www.getpostman.com/downloads/创建账号或者用谷歌浏览器账号登录一个demo了解一下我做的是一个app,后台使用java做的,app通过ajax来请求后台,但是我不知道后台有没有请求成功!因此需要一个测试接口的东西测试我做的接口有没有问题我的app里面的ajax是这样写的api.aja…

  • Nginx服务配置编写

    Nginx服务配置编写

发表回复

您的电子邮箱地址不会被公开。

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