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.

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

被折叠的 条评论
为什么被折叠?



