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. Concatenate the elements of values to create one long string. The ith 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 return this total goodness value.