#K59272. Max Commits in a Time Interval

    ID: 30828 Type: Default 1000ms 256MiB

Max Commits in a Time Interval

Max Commits in a Time Interval

You are given a list of commit timestamps (in minutes) and an interval length \(M\) (in minutes). Your task is to determine the maximum number of commits that occur within any continuous interval of \(M\) minutes.

Details:

  • The first input line contains two integers: \(n\), the number of commits, and \(M\), the interval length.
  • If \(n > 0\), the second line contains \(n\) space-separated integers representing the commit times; if \(n = 0\), the second line will be empty.
  • Find the maximum number of commit timestamps that can be covered by a continuous interval of length \(M\) minutes.

Examples:

Input:
5 60
10 20 30 100 110
Output:
3

Input: 7 15 1 2 3 14 15 30 31 Output: 5

</p>

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains two space-separated integers: \(n\) (the number of commits) and \(M\) (the interval length in minutes).
  2. If \(n > 0\), the second line contains \(n\) space-separated integers that represent the commit times in minutes. If \(n = 0\), the second line will be empty.

outputFormat

Print a single integer to standard output (stdout), which is the maximum number of commits found in any continuous interval of \(M\) minutes.

## sample
5 60
10 20 30 100 110
3

</p>