P10052 [CCO 2022] Double Attendance
Description
Because your school’s schedule is so strange, your two classes will start at the same time in two different classrooms. You can only be in one place at a time, so you can only walk back and forth between the two rooms, hoping to catch the key parts of both classes.
The two classrooms are numbered $1$ and $2$. In classroom $i$, the teacher will show $N_{i}$ different slides. The $j$-th slide is shown during the time interval $\left(A_{i, j}, B_{i, j}\right)\left(0 \leq A_{i, j}
Input Format
The first line contains three integers $N_{1}, N_{2}$, and $K$, separated by spaces.
The next $N_{1}$ lines each contain two integers $A_{1, i}$ and $B_{1, i}\left(1 \leq i \leq N_{1}\right)$, separated by spaces.
The next $N_{2}$ lines each contain two integers $A_{2, i}$ and $B_{2, i}\left(1 \leq i \leq N_{2}\right)$, separated by spaces.
Output Format
Output one integer, the maximum number of different slides you can see.
Explanation/Hint
## Explanation for Sample 1
One possible optimal strategy is to stay in classroom $1$ until time $11.5$, then move to classroom $2$ (arriving at time $19.5$), stay until time $19.6$, and finally return to classroom $1$ (arriving at time $27.6$). During this process, you will see all slides except the $3$-rd slide. It is impossible to see all $4$ slides.
## Explanation for Sample 2
Even if you move to classroom $2$ immediately when the classes begin (for example, at time $0.0001$), you will miss the first two slides shown there. Therefore, you can see at most four slides.
## Constraints
For all testdata, $1 \leq N_{i} \leq 3\times 10^5$, $0 \leq A_{i, j}