## GCC '16 P1 - Watching Anime

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type

A certain weeb wants to watch anime. However, he has commitments over the next hours, during which he cannot watch anime. To make matters worse, he is using a low quality streaming site that is only available for periods of time. Given his schedule over the next hours, figure out the total amount of time he can watch anime for.

#### Input Specification

The first line will contain 3 integers , , .
The next lines consist of 2 integers, , indicating that anime is streaming from hour to , inclusive.
The next lines consist of 2 integers, , indicating that the weeb in question cannot watch anime from hour to , inclusive.

For of points, .

#### Output Specification

The total amount of anime this weeb can watch, in hours.

#### Sample Input 1

20 3 2
1 3
2 4
3 10
1 4
10 20

#### Sample Output 1

5

#### Explanation for Sample Output 1

The weeb can watch anime from hour 5 to hour 9.

#### Sample Input 2

20 3 2
1 20
3 5
6 8
1 10
1 20

#### Sample Output 2

0

• commented on Dec. 22, 2016, 2:07 a.m.

Can any of the A time periods overlap?

• commented on Dec. 22, 2016, 2:14 a.m. edited

Yes.

• commented on Dec. 22, 2016, 2:14 a.m. edit 2

Yes. C time periods may overlap as well. In retrospect, it makes no sense to have overlapping commitments.

• commented on Dec. 22, 2016, 5:42 a.m.

He's just a really hard worker