company——桶思想

这篇博客探讨了桶思想在解决商品销售问题中的应用,强调了心态稳定的重要性,避免数组越界的问题。文章通过一个实例展示了如何根据商品的直接收益随时间变化来最大化总利润,给出了一种策略并提供了示例输入和输出。作者提醒读者注意数组越界错误,并分享了通过编程竞赛获得的思考。
摘要由CSDN通过智能技术生成

Think:
1桶思想
2反思:心态不稳,数组越界
3题意:n件物品,每件物品价值vali,每件物品库存cnti,for any goods sold on day i, if its direct benefit is val, the total benefit would be i⋅val.

company
Time Limit: 1000MS Memory Limit: 65536KB

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值