#P12379. Loose Subsequence Maximum Sum
Loose Subsequence Maximum Sum
Loose Subsequence Maximum Sum
Given a string s consisting only of lowercase letters, we define a loose subsequence as follows. Let t be a subsequence of s with positions p1, p2, ..., pk corresponding to characters in s. The subsequence t is called a loose subsequence if for all i > 1 the following holds:
$$p_i - p_{i-1} \geq 2$$
The value of a subsequence is defined as the sum of the values of the chosen characters, where the letters from a to z have values from 1 to 26 respectively, i.e.,
$$\text{value}(c) = \text{ord}(c) - \text{ord}('a') + 1, \quad c \in \{a,\dots,z\\}$$
Your task is to compute the maximum value attainable by any loose subsequence of s.
inputFormat
The input consists of a single line containing the string s (only lowercase letters).
Format: one string.
outputFormat
Output a single integer, which is the maximum value of any loose subsequence of s.
Format: one integer.
sample
abc
4