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


相关推荐

  • vite 基础配置

    vite 基础配置兼容老浏览器 默认情况下 Vite 只处理语法转译 且默认不包含任何 polyfill 通过引入 polyfill 可以前往 Polyfill io 查看 这是一个基于用户浏览器 User Agent 字符串自动生成 polyfill 包的服务 通过插件支持 通过插件 vitejs plugin legacy 来支持 它将自动生成传统版本的 chunk 及与其相对应 ES 语言特性方面的 polyfill 兼容版的 chunk 只会在不支持原生 ESM 的浏览器中进行按需加载公共基础路径

    2025年10月27日
    3
  • php 数学函数集锦

    php 数学函数集锦php 数学函数集锦

    2022年4月24日
    58
  • 操作系统知识整理 – 进程控制块

    操作系统知识整理 – 进程控制块前提系统中需要有描述进程存在和能够反映其变化的物理实体,即进程的静态描述。进程的静态描述由3部分组成:进程控制块(ProcessControlBlock,PCB),有关程序段和该程序段操作的数据结构集。PCB是系统感知进程的唯一实体,用于描述进程的当前情况以及管理进程运行的全部信息,是操作系统中最重要的记录型数据结构。程序段以及数据结构集是进程完成所需功能的物质基础。一个进…

    2025年6月25日
    4
  • string.hのstrcat的实现

    string.hのstrcat的实现

    2021年8月23日
    51
  • [数据库] 第一范式、第二范式、第三范式、BC范式

    [数据库] 第一范式、第二范式、第三范式、BC范式数据描述术语对应表关键码完全依赖、部分依赖、传递依赖第一范式、第二范式、第三范式

    2022年5月24日
    35
  • 【深度学习入门】——亲手实现图像卷积操作[通俗易懂]

    【深度学习入门】——亲手实现图像卷积操作[通俗易懂]深度学习中有一个很重要的概念就是卷积神经网络CNN,卷积神经网络中又有卷积层、池化层的概念。尤其是卷积层,理解难度比较大,虽然书中或者是视频中都有详细介绍过它的基础概念,但对于求知欲望很强烈的我,我总心里痒痒的,总想亲手实现,看看效果,怕的就是自己会眼高手低,做技术人最可怕的就是眼高手低。所以,我打算用python来亲自验证一遍。什么是卷积?卷积(convolution)是数学知…

    2022年5月8日
    75

发表回复

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

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