company(第八届山东省赛,贪心)

FreeSwitch采用mrcp协议对接科大讯飞asr和tts以及对话系统 FreeSwitch采用mrcp协议对接科大讯飞asr和tts对接过程 阅读详情

company

Problem Description

There are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its direct benefit is val, the total benefit would be i⋅val.
Beginning from the first day, you can and must sell only one good per day until you can't or don't want to do so. If you are allowed to leave some goods unsold, what's the max total benefit you can get in the end?

Input

The first line contains an integers n(1≤n≤1000).
The second line contains n integers val1,val2,..,valn(−100≤.≤100).
The third line contains n integers cnt1,cnt2,..,cntn(1≤≤100).

Output

Output an integer in a single line, indicating the max total benefit.

Sample Input
4
-1 -100 5 6
1 1 1 2
Sample Output
51
Hint

sell goods whose price with order as -1, 5, 6, 6, the total benefit would be -1*1 + 5*2 + 6*3 + 6*4 = 51.

Source
“浪潮杯”山东省第八届ACM大学生程序设计竞赛(感谢青岛科技大学)

思路:先把所有价值加入到一个vector中,然后从小到大排序,因为题目要求必须是连续卖物品,所以我们必须把价值为负的放在最前面卖(如果我们要卖负价值的物品的话),剩下的所有正价值的物品从小到大依次卖,越大越往后卖价值肯定越大,因为每个物品的实际卖的钱时它的价值乘所在天数,所以这道题目我只需要考虑到底加哪几个负值的物品可以是价值尽量大,因为前面加了负值的物品后面的物品会依次后移,天数就增加1,所以每增加一个负值的物品,正值的物品全部后移一天就相当于,多加了一个所有正值的和。所以我们只需要判断第k天卖负值时,这天减去的价值只要小于正值和,那么总价值一定是增加的。

因为每增加一个负值物品相当于增加价值 sum-a[i]*k,只要a[i]*k<sum,sum-a[i]*k就大于零,总价值就可以增加

code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> a;
int main(){
    int n;
    scanf("%d",&n);
    int q;
    for(int i = 0; i < n; i++){
        scanf("%d",&q);
        a.push_back(q);
    }
    for(int i = 0; i < n; i++){
        scanf("%d",&q);
        if(q > 1){
            for(int j = 0; j < q - 1; j++){
                a.push_back(a[i]);
            }
        }
    }
    sort(a.begin(),a.end());
    int pos = upper_bound(a.begin(),a.end(),0) - a.begin();
    ll sum = 0;
    for(int i = pos; i < a.size(); i++){
        sum += a[i];
    }
    bool ok;
    int record;
    for(int i = 0; i < pos; i++){
        int k = 1;
        for(int j = i; j < pos; j++){
            ll sum2 = 0;
            ok = 0;
            sum2 += a[j] * k;
            k++;
            if(abs(sum2) > sum){
                ok = 1;
                break;
            }
        }
        if(ok == 0){
            record = i;
            break;
        }
    }
    ll ans = 0;
    int cnt = 1;
    for(int i = record; i < a.size(); i++){
        ans += a[i] * cnt;
        cnt++;
    }
    printf("%lld\n",ans);
    return 0;
}

绿盾用户使用看图软件每次都需要把图片解密之后才能打开查看,怎么才能不用这么麻烦打开就能看 Win10专业版绿盾控制台7.0看图软件FastStone Image Viewer。 阅读详情

相关推荐

win 11bitlocker恢复密匙一般情况的解决方式(这里指的是你现在使用的微软账户一直没有变更过)

本来没有打算写这一篇解决帖子的,但是最近好多微博的友友都在私我询问解决方法,孩子虽然很热心,但是真的回复不过来了,打字太累了,这里给大家简单指个路,希望能够对大家有所帮助。 当时出现这个问题的时候,一搜网上的解决方法都是重装系统什么的,真是吓死孩子啦。后来去微软的官网倒腾了半天解决了问题。其实只要你没有改过微软账户,你可以直接试试我这个方法,大概三到五分钟解决问题吧。 和我情况不一样的也可以参考一下贴吧里一些大佬的分享,或者实在着急我感觉去淘宝上找个解决也不是未尝不可。 出现问题: 解决方案: 直接去微软

zhiqingxue的博客 2万+

山东省第八届 ACM 省赛 company (贪心、水)

Problem Description There are n kinds of goods in the company, with each of them has a inventory of cnti and direct unit benefit vali. Now you find due to price changes, for any goods sold on day i,

小坏蛋_千千 1607

告别WSL!用AMD ROCm7在Windows上跑ComfyUI,我的幻x2025 AI Max+ 395体验与性能调优心得

本文详细介绍了在搭载AMD Ryzen AI Max+ 395处理器的幻x2025笔记本上,如何通过ROCm7在Windows原生环境下高效运行ComfyUI,并分享了一系列性能调优技巧和实战经验,帮助开发者摆脱WSL束缚,提升AI创作效率。

weixin_29102619的博客 1111

第八届山东省赛题 J company 【贪心】

2018: J company 时间限制: 1 Sec  内存限制: 128 MB提交: 4  解决: 4[提交][状态][讨论版]题目描述There are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you find due to pri...

Emiya丶的博客 707

利用CubeMX复现正点原子TFTLCD驱动例程

①准备delay.c、delay.h、sys.c和sys.h四个文件。FMC的工作原理暂时先欠着,先记录一下CRUD的过程。这里我们使用的是BANK1 的第一个分区。点击 Configuration->FMC。②把fmc自动生成的代码注释掉一部分。配置参数如下图 17.5.1。③这个printf语句要屏蔽掉。选项卡之下配置相关参数。④整体代码,按需裁剪。

qq_59757948的博客 1612

基于深度学习的干扰识别

本文是记录我上半年仿真和复现干扰识别的过程,展示的主要是一些需要注意的点以及仿真的相关结果。

qq_55218335的博客 1702

第八届ACM山东省赛 J company

问题 J: J company 时间限制: 1 Sec  内存限制: 128 MB 提交: 2  解决: 2 [提交][状态][讨论版] 题目描述 There are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you fin

目标就是咸鱼!! 1122

深入解析逆时偏移(RTM)算法及其在C++中的实现

逆时偏移(Reverse Time Migration, RTM)是一种高级地震成像技术,广泛应用于地震勘探中。RTM通过逆时传播波场来构建地震子波,能够提供更高分辨率和更精确的地下构造图像。本文将详细介绍RTM的基本原理,并通过C++代码示例,深入解析如何实现和优化RTM算法。希望这篇文章能够为地球物理学家和C++开发者提供有价值的参考。

qq_38334677的博客 1526

company

题目描述 There are n kinds of goods in the company, with each of them has a inventory of cnti and direct unit benefit vali. Now you find due to price changes, for any goods sold on day i, if its direct

brambles-sea的博客 545

Claude Code、Codex、Gemini CLI、OpenCode 和 OpenClaw 配置管理太麻烦?试试这个统一管理工具

还在为 Claude Code、Codex、Gemini CLI 等 AI CLI 配置烦恼?🤯 这款桌面工具支持五大助手统一管理,一键切换 50+ 服务商,MCP 和 Skills 集中管理 🛠️,跨平台支持,让你的 AI 编程更高效 ⚡

XiaoqiangClub的博客 912

Mybatis面试题(基础篇)

(1)mybatis是支持定制化SQL、存储过程以及高级映射的优秀的持久层框架。(2)mybatis避免了几乎所有的JDBC代码(说明了mybatis底层用的就是JDBC,只不过是封装了)和手动设置参数以及获取结果集。(3)mybatis可以使用简单的XML或注解用于配置和原始映射,将接口和Java的pojo映射成数据库中的记录。

qq_38196449的博客 1686

2017第八届山东省赛总结

这次的省赛打的可谓是惊险,幸亏靠着手速才以银牌区最后一名的成绩水到银牌。先从热身赛开始说吧,B C 两题都很水,我基本是没参与队友便把这俩给切了,A题我看了之后想了一会认为是一个记忆化搜索,等队友把B C 切完之后我就开始搞A,很快就敲完了,测了几组数据之后没有问题,然后自信满满的交了一发,然后给我返回了一个RE,查了下代码之后以为可能是输入有非法数据导致数组访问越界,加了个特判之后又交了一发,结

liang654213的博客 584

从 VS Code 登录 ABAP Destination,一次把前后端连接跑通

最近很多 ABAP 开发者开始把 VS Code 纳入日常开发环境,原因很直接,VS Code 的轻量体验、命令面板、文件树、插件生态和 AI 编程能力,已经深深影响了现代开发者的工作方式。SAP 官方发布的 ABAP Development Tools for VS Code,也把 ABAP Cloud 开发模型带进了这个编辑器里。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 221

山东省第八届ACM省赛J题company(C-DP,贪心)

company Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description There are n kinds of goods in the company, with each of them has a inventory of  and direc

qq_37280023的博客 454

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

ACM 第八届山东省赛 J company SDUT 3902

题目再现链接:点击打开链接 company Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description There are n kinds of goods in the company, with each of them has a inventory of  an

Sizaif's 小屋 1856

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

山东省第八届ACM省赛 J 题(company)

Problem Description There are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its

JW12138的博客 1438

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

company(思维 + 贪心)

Problem DescriptionThere are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its dir...

码农的一亩三分地 2663

2017年ACM第八届省赛J题:Company - SDUT3902

Problem DescriptionThere are n kinds of goods in the company, with each of them has a inventory of  and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its dir...

675

company 贪心

companyTime Limit:1000 msMemory Limit:65536 KiBProblem DescriptionThere are n kinds of goods in the company, with each of them has a inventory of and direct unit benefit . Now you find due to price...

LMengi000的博客 317

贪心算法之子段和,山东省第八届acm大赛J题company,SDUT3902

company Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description There are n kinds of goods in the company, with each of them has a inventory of  and direct

雪的期许 1059

company[山东省第八届ACM大学生程序设计竞赛]

题目链接 Problem Description There are n kinds of goods in the company, with each of them has a inventory of and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if...

王小平 347

山东省赛--CF(01背包+贪心)

CF 1000 ms       65536 KiBSubmit Status My Status OriginDescriptionLYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes there are n problems, and for the ith...

sher杨的博客 337

山东省第八届ACM大学生程序设计竞赛 --- company (贪心+前缀和)

Problem Description There are n kinds of goods in the company, with each of them has a inventory of and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its d...

WangMeow --- ᶘ ᵒᴥᵒᶅ ฅ^•ﻌ•^ฅ 818
上一篇: quadratic equation(坑爹判断)
下一篇: CF(第八届山东省赛,01背包+贪心)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值