In the event of technical difficulties with Szkopuł, please contact us via email at firstname.lastname@example.org.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Byteman wants to go for a vacation and he would like to select the best days for that. He bases his choices on a weather forecast for the next days. He is only interested in the highest temperature anticipated for a given day.
Byteman is additionally constrained by terms set by his boss. During any consecutive days he can take no more than days of absence. What is the best way to plan the vacation, so that the sum of temperatures in the selected days is maximized?
The first line of the input contains two integers and (, , ). In the second line there are positive integers not exceeding that describe the temperatures anticipated for each of the next days.
Your program should output a single integer: the maximum possible sum of temperatures during vacation days picked with respect to boss' terms.
For the input data:
5 3 14 21 9 30 11 8 1 20 29 23 17 27 7 8 35
the correct result is:
Task author: Jakub Pachocki.