#C11873. Maximum Sum of Continuous Station Stop Times

    ID: 41237 Type: Default 1000ms 256MiB

Maximum Sum of Continuous Station Stop Times

Maximum Sum of Continuous Station Stop Times

You are given n stations with their corresponding stopping times and an integer k. Your task is to find the maximum sum of stopping times for any sequence of exactly k consecutive stations.

Formally, let the stopping times be represented as an array \(a_0, a_1, \dots, a_{n-1}\). You need to compute \[ \max_{0 \leq i \leq n-k} \left\{ \sum_{j=i}^{i+k-1} a_j \right\} \]

It is guaranteed that \(k \leq n\).

inputFormat

The first line contains two integers \(n\) and \(k\), where \(n\) is the number of stations and \(k\) is the number of consecutive stations to consider.

The second line contains \(n\) space-separated integers, each representing the stopping time at each station.

outputFormat

Output a single integer, which is the maximum sum of stopping times for any contiguous subsequence of exactly \(k\) stations.

## sample
5 3
1 2 3 4 5
12