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


相关推荐

  • 在线写java代码

    在线写java代码前言蓦然回首自己做开发已经十年了,这十年中我获得了很多,技术能力、培训、出国、大公司的经历,还有很多很好的朋友。但再仔细一想,这十年中我至少浪费了五年时间,这五年可以足够让自己成长为一个优秀的程序员,可惜我错过了,我用这五年时间和很多程序员一样在困惑和迷茫中找不到出路!路其实一直都在那里,只是我们看不到而已!以前我一直被公司和技术牵着走,并不是自己在选择技术,而是不自觉地被推到了这个位置上。想想有多少人对于自己将来要从事的职业和技术类型进行过深入思考和比较呢?当我跳出编码后,我开始思考和程序及程序员职

    2022年7月8日
    26
  • python分组排序_Python 排序分组问题

    python分组排序_Python 排序分组问题_list=[{‘value’:123,’upclock’:1234567},{‘value’:423,’upclock’:2123},{‘value’:123,’upclock’:1234567},{‘value’:423,’upclock’:1123},{‘value’:423,’upclock’:1123},{‘value’:872,’upclock’:…

    2022年6月16日
    33
  • 分类指标准确率(Precision)和正确率(Accuracy)的区别「建议收藏」

    分类指标准确率(Precision)和正确率(Accuracy)的区别「建议收藏」http://www.cnblogs.com/fengfenggirl/p/classification_evaluate.html一、引言分类算法有很多,不同分类算法又用很多不同的变种。不同的分类

    2022年8月3日
    11
  • redhat7安装图形化界面命令_红旗linux官网

    redhat7安装图形化界面命令_红旗linux官网redflaglinuxdesktop5.0对硬件的基本要求是多高?(转)[@more@]从中科红旗的网站(http://www.redflag-linux.com/chanpin/ws5/ws5.html)里下载的红旗桌…

    2022年8月20日
    6
  • 2021年最新Java学习路线图指南

    2021年最新Java学习路线图指南Java在编程语言排行榜中一直牢牢占据榜首位置,几乎所有的大中型互联网的应用系统在服务器端开发首选都是Java编程,正因如何吸引这不少年轻人投入该行业,Java虽不想其它编程语言那么复杂,但是知识体系还是很庞大的,因此想要学好并非容易之事,不少想要跨入Java编程行业的同学们通过网络搜索各式各样的学习资料,却往往缺乏系统而全面的学习路线。动力节点深知同学们的学习困难,为此整理了一套最新的2021年新版学习路线图,增加了目前企业最新应用技术,这套学习路线图,只要你完成一半基本就可以找到很不错的…

    2022年5月17日
    42
  • zencart 引用模板语句「建议收藏」

    zencart 引用模板语句「建议收藏」例如引用:head模板:&lt;?php/***preparesanddisplaysheaderoutput**/if(CUSTOMERS_APPROVAL_AUTHORIZATION==1&amp;&amp;CUSTOMERS_AUTHORIZATION_HEADER_OFF==’true…

    2022年7月27日
    4

发表回复

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

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