eolymp
bolt
Try our new interface for solving problems
Problems

Elective System

Elective System

The students at Byteland Institute of Technology are registering electronically for classes. Registration is open for a predetermined number of time units, and each time unit is assigned a positive number called the goodness. Higher goodness values mean that the network is more likely to be available and responsive during those time units. You may log in at most $k$ times during the registration period. Each login may last a maximum of $d$ time units, and logins must not overlap with each other. You are given a string values. The $i$-th character of this string represents the goodness value of the ith time unit. The goodness values are given as characters '$a$' to '$z$', which represent values $1$ to $26$, respectively. Choose a strategy that maximizes the total goodness of the time units during which you are logged in, and find this total goodness value. \InputFile The first line of each test case containsthe values of $d$ and $k\:(1 \le d, k \le 1000)$. The second line contains the string values that contains no more than $1000$ letters '$a$' --- '$z$'. \OutputFile For each test case print in a separate line the maximal possible total goodness value.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4 1
acacca
2 2
cabcca
2 18
yptcsevnuzlsrfjxurpslztlinhddelpitmvaezowjcfjjfgmfq
Output example #1
10
10
598