ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Строки > задача:


Hexatridecimal Sum

Задачи раздела

• Magic Words
• Hexatridecimal Sum
• Text Statistics
• Арифметическое выражение
• Панграмма-1
• Панграмма-2
• Редкое имя

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Сложность Гамма

Hexatridecimal notation is base 36 notation. The digits are '0' to '9' (with values 0 to 9) and 'A' to 'Z' (with values 10 to 35).

You are given N numbers, where each number is a positive integer in hexatridecimal notation. You must select exactly k digits (from the set of all digits - '0' to '9' and 'A' to 'Z') and replace all of their occurrences in all of the numbers with 'Z'. Then, calculate the sum of all the numbers. Find the maximal possible sum you can get.

Input
The first line contains two integer numbers N and k (1 ≤ N ≤ 50, 0 ≤ k ≤ 36). The following N lines will contain one number per line in hexatridecimal notation. Each number will contain between 1 and 50 characters, inclusive. Each number contain only characters '0' to '9' and 'A' to 'Z'. Each number will not start with '0'.
Output
In the single line output the maximal possible sum, that you can get. The sum must be in hexatridecimal format with no leading zeroes.

Input 1 Input 2 Input 3 Input 4 Input 5
1 2
HELLO
5 5
500
POINTS
FOR
THIS
PROBLEM
6 0
TO
BE
OR
NOT
TO
BE
1 36
KEQUALS36
5 7
GOOD
LUCK
AND
HAVE
FUN
Output 1 Output 2 Output 3 Output 4 Output 5
ZZLLO
1100TC85
QNO
ZZZZZZZZZ
31YUB

Для отправки решений необходимо выполнить вход.

www.contester.ru