HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Problems from everywhere > problem:


TopCoder-5. 50760 - Hexatridecimal Sum

Guest
• Discussion of problem (1)

Volume problems

• 50602 - Birthday Ivanova
• 50603 - Rider
• 50613 - Zapakovka
• 50622 - Sequence
• 50643 - Stepeny couples
• 50644 - Capital
• TopCoder-1. 50761 - Magic Words
• TopCoder-2. 50246 - Making Potions
• TopCoder-5. 50760 - Hexatridec...
• VologdaInterUni-A. 50628 - Matrix
• VologdaInterUni-E. 50619 - The Mar...
• VologdaInterUni-F. 50638 - Message
• VologdaInterUni-G. 50639 - Brackets
• VologdaInterUni-H. 50648 - Translator

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Gamma

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