eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Another word sorting

Another word sorting

A new scoring system for a word is invented and described as follows. Each letter has a value according to its alphabetic position e.g. \textbf{a=1}, \textbf{b=2}, \textbf{c=3}, ..., \textbf{z=26}. The score of a word is the sum of values of its letters plus the bonus. When a word has double letters (\textbf{2} consecutive same letters), it will obtain the bonus of \textbf{2} times the letter value. Take a look at these examples: \textbf{apple = (1+16+16+12+5) + bonus 2x16 = 82} \textbf{banana = (2+1+14+1+14+1) = 33 (no bonus)} \textbf{orange = 15+18+1+14+7+5 = 60 (no bonus)} \textbf{acted = (1+3+20+5+4) = 33 (no bonus)} \textbf{commit = 3+15+13+13+9+20 + bonus 13x2 = 99} A letter can be used to calculate the bonus only once. Given a list of words, your task is to rearrange them in descending order of their scores. In case of equal score, sort the words lexicographically. \InputFile The input contains a sequence of words each in a separate line. Each word contains only lower case letters (\textbf{a}...\textbf{z}) and has no more than \textbf{20} letters. The input can contain up to one \textbf{1000} lines. \OutputFile The output includes a sequence of the input words rearranged by this method. Each line contains only one word. If there are duplicate words, conserve all of them. There are neither blanks nor blank lines in the output.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
apple
banana
commit
orange
acted
apple
ieee
Вихідні дані #1
commit
apple
apple
orange
ieee
acted
banana