P2209 [USACO13OPEN] Fuel Economy S

Description

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

Input Format

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

Output Format

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

Explanation/Hint

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