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


相关推荐

  • 人物关系图谱:ECharts 实现

    人物关系图谱:ECharts 实现1、什么是EChartsECharts是百度开源的纯Javascript图表库,目前开源可以与highcharts相匹敌的一个图表库,相信有很多国内用户使用。官网http://echarts.baidu.com/2、开始简单配置关系图1、首先配置series的type为graph。2、layout为force,layout可以选择none、circular和force…

    2022年6月26日
    21
  • Webstorm激活码 2021【2021.7最新】

    (Webstorm激活码 2021)最近有小伙伴私信我,问我这边有没有免费的intellijIdea的激活码,然后我将全栈君台教程分享给他了。激活成功之后他一直表示感谢,哈哈~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月21日
    46
  • SpringMVC @ResponseBody 415错误处理

    SpringMVC @ResponseBody 415错误处理闲话少说,刚开始用SpringMVC,页面要使用jquery的ajax请求Controller。但总是失败,主要表现为以下两个异常为:异常一:java.lang.ClassNotFoundException:org.springframework.http.converter.json.MappingJacksonHttpMessageConverter异常二

    2022年6月10日
    29
  • 【stm32f407】SPI实验 驱动W25Q128「建议收藏」

    一.SPI介绍SPI是英语SerialPeripheralinterface的缩写,顾名思义就是串行外围设备接口。是Motorola首先在其MC68HCXX系列处理器上定义的。SPI接口主要应用在EEPROM,FLASH,实时时钟,AD转换器,还有数字信号处理器和数字信号解码器之间。SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚…

    2022年4月7日
    40
  • fstream头文件的作用_Ofstream需要什么头文件

    fstream头文件的作用_Ofstream需要什么头文件…

    2022年9月19日
    0
  • 怎么算图中有多少个三角形_贪心算法经典例题

    怎么算图中有多少个三角形_贪心算法经典例题题目:请说出下面图形中包含多少个三角形?请用一个程序完成计算。C++版本解题思路:(1)给每个交点做标记,如下:(2)总共有36条线段,如果三条线段两两之间存在交点,但一条线上(已经包含了三条

    2022年8月1日
    4

发表回复

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

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