[USACO13OPEN] Fuel Economy S


Farmer John has decided to take a cross-country vacation. Not wanting his cows to feel left out, however, he has decided to rent a large truck and to bring the cows with him as well! The truck has a large tank that can hold up to G units of fuel (1 <= G <= 1,000,000). Unfortunately, it gets very poor mileage: it consumes one unit of fuel for every unit of distance traveled, and FJ has a total of D units of distance to travel along his route (1 <= D <= 1,000,000,000). Since FJ knows he will probably need to stop to refill his tank several times along his trip, he makes a list of all the N fuel stations along his route (1 <= N <= 50,000). For each station i, he records its distance X\_i from the start of the route (0 <= X\_i <= D), as well as the price Y\_i per unit of fuel it sells (1 <= Y\_i <= 1,000,000). Given this information, and the fact that FJ starts his journey with exactly B units of fuel (0 <= B <= D), please determine the minimum amount of money FJ will need to pay for fuel in order to reach his destination. If it is impossible for him to reach the destination, please output -1. Note that the answer to this problem may not fit into a standard 32-bit integer. Farmer John 决定去一次跨国旅游度假。为了不让他的奶牛们感到被抛弃,他决定租一辆大卡车来带他的奶牛们一起旅行。 这辆卡车有一个很大的油箱,可以装下 $G$ 个单位的油($1 \le G \le {10}^6$),不幸的是,卡车的耗油量也很大,卡车每运动一个单位的距离,就要消耗一个单位的油。Farmer John 要在他的旅程中走 $D$ 个单位的距离。($1 \le D \le {10}^9$) 因为 FJ 直到他可能要几次在旅途中停下,给油箱加油,所以他把在旅途沿路上的 $N$ 个加油站的记录做成了表格。对于第 $i$ 个加油站,他记录了加油站与起点的距离 $X_i$($0 \le X_i \le D$),以及加油站中每单位油的价格 $Y_i$($1 \le Y_i \le {10}^6$)。 已知以上所给的信息,以及 FJ 在路途开始时拥有的燃油的数量 $B$($0 \le B \le D$),请计算出 FJ 到达目的地时花费的油费用的最小值。如果 FJ 无法到达旅途的终点,那么请输出 `-1`。本题的答案可能无法使用 32 位整数储存。



第一行: 四个整数:$N, G, B, D$ 接下来 $N$ 行:每一行都有两个整数 $X_i$ 与 $Y_i$,意义如上所述


一个整数,如果 FJ 无法到达旅途的终点,那么输出 `-1`,否则输出 FJ 到达目的地时花费的油费用的最小值。


输入样例 #1

4 10 3 17
2 40
9 15
5 7
10 12

输出样例 #1



样例解释:FJ 先移动 $2$ 个单位,然后停下购买 $2$ 个单位的油(要花费 $40 \times 2$)。然后一直前进到距离起点 $5$ 个单位的地方,此时油箱为空。这时向油箱里加满油(要花费 $7 \times 10$)。再向前走 $5$ 个单位,加 $2$ 个单位的油(花费 $12 \times 2$)。最后一直走到终点。此时总花费是 $174$。