#K93637. Maximum Apples Harvest Problem

    ID: 38464 Type: Default 1000ms 256MiB

Maximum Apples Harvest Problem

Maximum Apples Harvest Problem

Given N days and an array representing the number of apples harvested each day, your task is to determine the maximum number of apples that can be obtained over any consecutive k days.

The problem can be formulated mathematically as follows:

$$\max_{0 \leq i \leq N-k} \sum_{j=i}^{i+k-1} a_j$$

where \(a_j\) represents the number of apples harvested on the \(j^{th}\) day.

inputFormat

The first line contains two space-separated integers, N (the number of days) and k (the length of the consecutive period to consider).

The second line contains N space-separated integers, each representing the number of apples harvested on that day.

outputFormat

Output a single integer which is the maximum sum of apples that can be harvested over any consecutive k days.

## sample
7 3
1 2 3 4 5 6 7
18