#C604. Max Total Price of K Consecutive Products
Max Total Price of K Consecutive Products
Max Total Price of K Consecutive Products
Given an integer \(K\) and a list of product prices, your task is to find the maximum total price of any \(K\) consecutive products in the list. You are to implement a function that reads from standard input and writes the result to standard output.
The first line of the input contains an integer \(K\) which represents the number of consecutive products to consider. The second line contains the product prices separated by spaces. Your program should compute the maximum possible sum of any consecutive group of \(K\) products.
Note: The input is guaranteed to have at least \(K\) numbers.
inputFormat
The input is provided via standard input (stdin) in the following format:
K price_1 price_2 ... price_n
Where:
K
is an integer representing the number of consecutive products to evaluate.price_1, price_2, ... , price_n
are space-separated integers representing the product prices.
outputFormat
Output a single integer to standard output (stdout) representing the maximum total price of any \(K\) consecutive products.
## sample3
1 12 5 7 9 3
24