There are N cities placed in a line. For each city i you know its coodinate xi and the amount of money wi its citizens have.
You are a robber and you have a car intially placed at coordinate X. The car has enough gas to last you for K kilometers (each kilometer is represented as a unit on the axis). When you pass through a city you steal all the money of its citizens.
What is the maximum total amount you can steal? You can change direction as you wish, but you can't rob the same city twice.
The first line contains three integers N, X, and K.
Each of the next N lines contains two integers x and w representing the coordinate of a city and the amount of money its citizens have.
Print a single integer representing the total amount you can steal.
Input | Output |
---|---|
4 0 3 -4 10 -1 1 1 1 4 10 | 2 |
4 0 4 -4 10 -1 1 1 1 4 10 | 11 |
4 3 7 0 9 4 1 5 5 7 8 | 15 |