当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5380:Travel with candy

题目描述
There are n+1 cities on a line. They are labeled from city 0 to city n. Mph has to start his travel from city 0, passing city 1,2,3...n-1 in order and finally arrive city n. The distance between city i and city 0 is $a_i$. Mph loves candies and when he travels one unit of distance, he should eat one unit of candy. Luckily, there are candy shops in the city and there are infinite candies in these shops. The price of buying and selling candies in city i is $buy_i$ and $sell_i$ per unit respectively. Mph can carry at most C unit of candies.
Now, Mph want you to calculate the minimum cost in his travel plan.
输入解释
There are multiple test cases.
The first line has a number T, representing the number of test cases.
For each test :
The first line contains two numbers $N$ and $C$ $(N \leq 2\times 10^5, C\leq 10^6)$
The second line contains $N$ numbers $a_1,a_2,...,a_n$. It is guaranteed that $a_i>a_{i-1}$ for each $ 1< i<=N$ .
Next $N+1$ line : the i-th line contains two numbers $buy_{i-1}$ and $sell_{i-1}$ respectively. ($sell_{i-1} \leq buy_{i-1} \leq 10^6$)

The sum of $N$ in each test is less than $3\times 10^5$.
输出解释
Each test case outputs a single number representing your answer.(Note: the answer can be a negative number)
输入样例
1
4 9
6 7 13 18
10 7
8 4
3 2
5 4
5 4
输出样例
105
来自杭电HDUOJ的附加信息
Author SXYZ
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5380

最后修改于 2020-10-25T23:22:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)