## 25 Jul Aurora Wednesday 18:30 Python Practice 22.07.20.

**Question:**

Kenny wants to go trick-or-treating too! But the street has many spooky decorations put up on it. Kenny doesn’t like to be scared, so he avoids spooky areas.

There are L houses arranged in a line on the street, numbered from 1 to L. Each house will give exactly 1 unit of candy to Kenny. There are N spooky decorations on this street. The ** i**-th decoration covers the street from house number a

*to b*

_{i}*, inclusive, raising the spookiness of those houses by s*

_{i}*spookiness units.*

_{i}Kenny will be too scared to knock on any doors if the spookiness of a house is greater than or equal to S. The spookiness of a house is the sum of the spookinesses of all the decorations passing through it.

Determine the amount of candy Kenny can receive from all the houses on the street.

**Input Specification**

The first line of input will contain the integers: N, L, S (1 ≤ N ≤ 10000; 1 ≤ L ≤ 109; 1 ≤ S ≤ 107).

The next N lines of input will contain values a, b and s for each house. (1 ≤a* _{i}*, b

*≤ 109; 1 ≤ s*

_{i }*≤ 1000).*

_{i }**Output Specification**

Output a single integer, the amount of candy that Kenny can get.

Sample Input 13 100 10 20 59 4 30 69 4 40 79 4Sample Output 180Explanation 1Houses between number 40 and 59 inclusive have a spookiness of 12, which is 2spooky for Kenny. He can still get candy from houses 1 to 39, and 60 to 100.Sample Input 22 10 4 3 5 2 5 7 2Sample Output 29Explanation 2Only house 5 is 2spooky for Kenny.

Sorry, the comment form is closed at this time.