View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Julia likes avocado trees. She maintains a strip of trees by a river. All of the trees are grown in along a straight line. However, Rose the avocado-robber has just made it into town. Rose would like to steal all the avocados from Julia's trees, but she also knows that Julia keeps her trees well guarded. This means that Rose will only get one chance to raid Julia. Additionally, Rose is short, and so can only steal from trees with height at most . Rose has also decided to not attempt to hit all the trees, but will instead focus on one contiguous range of trees (presumably to lower chances of being seen).

Rose has created a list of all the ranges she is considering to steal from. Since she can only steal from one range before having to escape, write a program to find the maximum number of avocados she can steal.

#### Input Specification

The first line will contain three integers: , denoting the number of trees Julia has, , the number of possible ranges Rose has on her list, and , the maximum height Rose can steal from.

The next lines will contain two integers: , denoting the height of the tree at position , and , denoting the avocado yield of that particular tree.

The next lines will contain two integers and , denoting that the range Rose has chosen begins at and ends at (inclusive).

#### Output Specification

Output a single integer, the maximum number of avocados Rose can obtain from a single range.

#### Sample Input

5 2 3
1 3
4 2
3 3
2 1
1 1
1 3
2 5

#### Sample Output

6

#### Explanation for Sample Output

The first range is from tree to tree , which will give Rose avocados since the tree at index is too tall for Rose to steal from. The second range from tree to tree will only yield avocados. Therefore, the maximum avocados that can be obtained in a single one of the ranges is .