#K36247. Consecutive Browsing Sessions
Consecutive Browsing Sessions
Consecutive Browsing Sessions
You are given a sorted list of visit timestamps and an integer ( k ). Two consecutive visits are considered to be part of the same session if the difference between their timestamps is at most ( k ) minutes. Otherwise, a new session begins. Your task is to calculate and output the length of each consecutive browsing session.
For example, if the timestamps are ( [1, 3, 4, 10, 12, 13] ) and ( k = 5 ), then visits ( 1, 3, 4 ) form the first session because ( 3-1 ) and ( 4-3 ) are ( \leq k ). The next session is ( [10, 12, 13] ).
inputFormat
The input consists of two lines. The first line contains two integers ( n ) and ( k ), where ( n ) is the number of timestamps and ( k ) is the maximum allowed gap in minutes between consecutive timestamps for them to be considered part of the same session. The second line contains ( n ) space-separated integers representing the timestamps in non-decreasing order.
outputFormat
Output the lengths of each consecutive session in the order they appear, separated by a single space.## sample
6 5
1 3 4 10 12 13
3 3
</p>