#K7526. Maximum Potion Effectiveness
Maximum Potion Effectiveness
Maximum Potion Effectiveness
You are given a sequence of herbs represented by their effectiveness values. Your task is to select exactly K consecutive herbs and compute the maximum possible sum of their effectiveness values.
Formally, given an array \(a_1, a_2, \dots, a_N\) and an integer \(K\), you need to determine the maximum value of \[ S = \max_{1 \leq i \leq N-K+1} \sum_{j=i}^{i+K-1} a_j \] Make sure your solution reads the input from standard input (stdin) and writes the output to standard output (stdout).
inputFormat
The first line of input contains two integers N and K separated by a space, which represent the number of herbs and the number of consecutive herbs to consider, respectively.
The second line contains N integers separated by spaces, representing the effectiveness values of the herbs.
outputFormat
Output a single integer, which is the maximum possible sum of any K consecutive herbs.
## sample5 3
1 -2 3 4 -1
6