#C4921. Average Duration Between Events
Average Duration Between Events
Average Duration Between Events
You are given a sequence of event timestamps in the format HH:MM:SS
. Your task is to calculate the average time interval between consecutive events. Formally, if the timestamps are denoted as \( t_1, t_2, \ldots, t_n \) (in seconds), then you need to compute the average interval defined by
\[ \text{Average} = \left\lfloor \frac{\sum_{i=1}^{n-1}(t_{i+1} - t_i)}{n-1} \right\rfloor \]\
The result should be output in the HH:MM:SS
format where hours, minutes, and seconds are zero-padded to two digits.
inputFormat
The input is read from stdin
and is structured as follows:
- The first line contains an integer ( n ) (with ( n \ge 2 )), representing the number of events.
- The following ( n ) lines each contain a timestamp in the
HH:MM:SS
format.
The events are given in chronological order.
outputFormat
The output is written to stdout
. It should contain a single line with the average duration between consecutive events in HH:MM:SS
format.## sample
5
12:34:56
12:35:56
12:36:00
13:00:00
13:01:00
00:06:31