#C11907. Maximum Heat Likes

    ID: 41275 Type: Default 1000ms 256MiB

Maximum Heat Likes

Maximum Heat Likes

You are given an integer N representing the number of posts and an integer L representing the length of the contiguous segment to consider. You are also given an array of N integers, where each integer represents the likes of a post. Your task is to compute the maximum sum of likes obtainable by any contiguous subarray of length L.

If we denote the likes array as likes, the objective is to calculate

$$\max_{0 \le i \le N-L} \sum_{j=i}^{i+L-1} likes[j]$$

If N < L, you must output an error message: "Invalid input: N should be greater than or equal to L".

inputFormat

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

  • The first line contains two space-separated integers: N and L.
  • The second line contains N space-separated integers representing the likes of each post.

outputFormat

Output a single line to standard output (stdout) containing the maximum sum of likes over any contiguous subarray of length L. If N < L, output the following error message exactly:

Invalid input: N should be greater than or equal to L

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

</p>