### PEG Test - Halloween 2014

## Problem C: 2spooky4me

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 _{i}` to

`b`, inclusive, raising the spookiness of those houses by

_{i}`s`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 Format

The first line of input will contain the integers: `N`, `L`, `S` (1 ≤ `N` ≤ 10000; 1 ≤ `L` ≤ 10^{9}; 1 ≤ `S` ≤ 10^{7}).

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

`b`≤ 10

_{i}^{9}; 1 ≤

`s`≤ 1000).

_{i}### Output Format

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

### Sample Input 1

3 100 10 20 59 4 30 69 4 40 79 4

### Sample Output 1

80

### Explanation 1

Houses 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 2

2 10 4 3 5 2 5 7 2

### Sample Output 2

9

### Explanation 2

Only house 5 is 2spooky for Kenny.

All Submissions

Best Solutions

**Point Value:** 7

**Time Limit:** 2.00s

**Memory Limit:** 16M

**Added:** Nov 07, 2014

**Authors:** Alex, frenzybenzy

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

jeffreyxiaoon Nov 07, 2014 - 4:12:26 am UTC Question can't be done in javaFatalEagleon Nov 07, 2014 - 4:16:29 am UTC Re: Question can't be done in javajeffreyxiaoon Nov 07, 2014 - 4:29:44 am UTC Re: Question can't be done in javajargonon Nov 08, 2014 - 1:31:42 am UTC Re: Question can't be done in java