CF1059A.Cashier

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Cashier

Vasya has recently got a job as a cashier at a local store. His day at work is LL minutes long. Vasya has already memorized nn regular customers, the ii-th of which comes after tit_{i} minutes after the beginning of the day, and his service consumes lil_{i} minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer.

Vasya is a bit lazy, so he likes taking smoke breaks for aa minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?

Input

The first line contains three integers nn, LL and aa (0n1050 \le n \le 10^{5}, 1L1091 \le L \le 10^{9}, 1aL1 \le a \le L).

The ii-th of the next nn lines contains two integers tit_{i} and lil_{i} (0tiL10 \le t_{i} \le L - 1, 1liL1 \le l_{i} \le L). It is guaranteed that ti+liti+1t_{i} + l_{i} \le t_{i + 1} and tn+lnLt_{n} + l_{n} \le L.

Output

Output one integer  — the maximum number of breaks.

Note

In the first sample Vasya can take 33 breaks starting after 22, 55 and 88 minutes after the beginning of the day.

In the second sample Vasya can take 22 breaks starting after 00 and 22 minutes after the beginning of the day.

In the third sample Vasya can't take any breaks.

Samples

2 11 3
0 1
1 1
3
0 5 2
2
1 3 2
1 2
0

在线编程 IDE

建议全屏模式获得最佳体验