1306: company

内存限制:64 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:97 解决:30

题目描述

There arenkinds of goods in the company, with each of them has a inventory ofcntiand direct unit benefitvali. Now you find due to price changes, for any goods sold on dayi, if its direct benefit isval, the total benefit would beival.
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?

输入

The first line contains an integersn(1n1000).
The second line contains
nintegersval1,val2,..,valn(−100vali.100).
The third line contains
nintegerscnt1,cnt2,..,cntn(1cnti100).

输出

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

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.

样例输入复制

4 -1 -100 5 6 1 1 1 2

样例输出复制

51
Baidu
map