#P12244. 踩点
踩点
Description
Today is another school day with classes. The -th class starts at the beginning of minute and ends at the beginning of minute .
Little O wants to play basketball during every break between classes. However, the round-trip between the classroom and the playground takes a total of minutes.
Little O will go to play basketball during a break if and only if he can return to the classroom without being late for the next class. Otherwise, he stays in the classroom.
How many total minutes will Little O spend playing basketball today?
Input Format
- The first line contains two integers and , representing the number of classes and the round-trip time.
- The next lines each contain two integers and , describing the start and end time of the -th class.
Output Format
Output one integer: the total minutes Little O spends playing basketball.
3 2
1 2
5 7
8 9
1
Hint
Sample #1 Explanation
- Break 1 (between classes 1 and 2): Duration = minutes. After spending minutes on the round-trip, Little O plays for minute.
- Break 2 (between classes 2 and 3): Duration = minute. The round-trip requires minutes, so he skips it.
Total play time: minute.
Constraints
- For : (classes are non-overlapping and ordered chronologically).
Subtasks
- 20%:
- 20%:
- 20%:
- 40%: No additional constraints
京公网安备 11011102002149号