#K95162. Calculate Total Free Time Between Meetings
Calculate Total Free Time Between Meetings
Calculate Total Free Time Between Meetings
You are given a list of non-overlapping meeting intervals. Each meeting is represented as a pair of integers ( (start, end) ) in hours. Your task is to determine the total free time available between these meetings. The free time between two consecutive meetings is defined by the gap ( gap = start_{i} - end_{i-1} ) for ( i \ge 2 ). If there are no meetings or only one meeting, the free time is 0.
For example, given the meetings:
- [(1, 3), (5, 6), (8, 10)]
This problem tests your ability to process input data, sort the intervals, and accurately compute the sum of the gaps between meetings.
inputFormat
The input is given from standard input (stdin). The first line contains an integer ( n ) representing the number of meetings. Each of the following ( n ) lines contains two space-separated integers representing the start and end times of a meeting.
outputFormat
Output a single integer to standard output (stdout), which is the total free time calculated between the meetings.## sample
0
0