#C6918. Total Awake Time
Total Awake Time
Total Awake Time
Given a number of dragons and their respective active intervals, compute the total time during which at least one dragon is awake. Each interval is defined by two integers \( s \) and \( e \), where the dragon is active from time \( s \) (inclusive) to time \( e \) (exclusive).
If intervals overlap, ensure that the overlapping period is only counted once. This problem requires careful handling of interval merging to avoid double counting.
inputFormat
The input is given in the following format:
- The first line contains a single integer \( m \), the number of dragons.
- The next \( m \) lines each contain two space-separated integers \( s \) and \( e \), representing the start and end times of a dragon's activity period.
outputFormat
Output a single integer that represents the total duration during which at least one dragon is awake.
## sample1
1 4
3