P10566 "Daily OI Round 4" Analysis
Description
Xiao C's IT teacher assigned Xiao C some homework, as follows:
> There is a string containing uppercase letters, lowercase letters, and digits. You may change any character into another character. Suppose the ASCII code of the character before the change is $a$, and after the change is $b$. Then this change costs $|a-b|$ units of time. You need to turn the entire string into a string that contains only uppercase letters.
Xiao C also has many other important assignments such as Chinese, math, and English. To save time, you need to calculate the minimum time Xiao C needs to make the string contain only uppercase letters.
Input Format
One line containing a string $s$, which is the string given by the teacher.
Output Format
One line containing a non-negative integer $t$, representing the minimum total time needed to make the string contain only uppercase letters.
Explanation/Hint
#### Sample Explanation
For the first sample, the best way is to change it into $\texttt{AAAZZ}$. Then the cost is $0+0+|48-65|+|97-90|+|97-90|=31$. It is easy to prove that there is no better solution.
Here, $48$ is the ASCII code of character $\texttt{0}$, $65$ is the ASCII code of character $\texttt{A}$, $90$ is the ASCII code of character $\texttt{Z}$, and $97$ is the ASCII code of character $\texttt{a}$.
#### Constraints
**This problem uses bundled testdata.**
Let $len$ be the length of string $s$.
| $\text{Subtask}$ | Score | $len \le$ |
| :-----------: | :-----------: | :-----------: |
| $0$ | $10$ | $3$ |
| $1$ | $30$ | $10$ |
| $2$ | $60$ | $10^5$ |
For all testdata, it is guaranteed that $1 \le len \le 10^5$, and $s$ contains only uppercase letters, lowercase letters, and digits.
Translated by ChatGPT 5