HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Strings > problem:


50760 - Hexatridecimal Sum

Guest
• Discussion of problem (1)

Section problems

• 50908 - Buy 1 Get 1
• 50761 - Magic Words
• 50760 - Hexatridecimal Sum
• 50759 - Text Statistics
• 50246 - Making Potions
• 50258 - String manipulations
• 50264 - String Multiplication
• 50307 - Palindromes
• 50315 - Pig Latin
• 50484 - Number Of Letters
• 50323 - Filtering Contact List

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