#K57722. Maximum Tasks in Consecutive Days

    ID: 30484 Type: Default 1000ms 256MiB

Maximum Tasks in Consecutive Days

Maximum Tasks in Consecutive Days

You are given a list of tasks scheduled on different days and an integer k representing the number of consecutive days available for performing tasks. Each day, you can complete at most one task. Your goal is to determine the maximum number of tasks that can be completed in any period of k consecutive days.

The answer is computed by considering that if there are n tasks provided, then in any k-day window, you can only complete at most one task per day. Thus, the maximum number of tasks you can complete is min(n, k), where n is the total number of tasks. Edge cases include an empty task list (where n = 0), in which case no task can be completed.

Note that although each task comes with an associated value, the value itself does not affect the result. Only the count of tasks is important.

inputFormat

The input is provided via standard input (stdin). The first line contains two space-separated integers: n (the number of tasks) and k (the number of consecutive days).

If n > 0, the second line contains n space-separated integers representing the tasks. If n = 0, there will be no second line.

outputFormat

Output a single integer to standard output (stdout) representing the maximum number of tasks that can be completed in any k consecutive days.

## sample
5 3
1 2 3 4 5
3