Company: Turing_7may
Difficulty: medium
Problem 1 Description In an enchanted dungeon, n wizards stand in a row. Each wizard has an energy value: landing on a wizard with a positive value gives you that much energy, and landing on a wizard with a negative value drains that much energy from you. You are cursed so that the moment you absorb the energy of the wizard at position i , you are teleported to the wizard at position i + k . The curse keeps teleporting you, and you keep absorbing energy from every wizard you land on, until i + k runs past the end of the row - only then does the journey stop. You may pick any wizard in the row as your starting point. Given the array energy and the integer k , determine the maximum total energy you can collect. Input Format The first line contains the array energy in bracket notation: values separated by commas, with no spaces, for example [7,-3,8,-2,4] . The second line contains the integer k . Output Format Print a single integer: the maximum total energy collectible. The answer may be