HexatridecimalSum
SRM 434 · 2009-02-07 · by darnley
Problem Statement
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 a
Return the maximal possible sum you can get. The return value must be in hexatridecimal format with no leading zeroes.
Constraints
- numbers will contain between 1 and 50 elements, inclusive.
- Each element of numbers will contain between 1 and 50 characters, inclusive.
- Each element of numbers will contain only characters '0' to '9' and 'A' to 'Z'.
- Each element of numbers will not start with '0'.
- k will be between 0 and 36, inclusive.
{"HELLO"}
2
Returns: "ZZLLO"
It is optimal to change the two most significant digits in the given number.
{"500", "POINTS", "FOR", "THIS", "PROBLEM"}
5
Returns: "1100TC85"
{"TO", "BE", "OR", "NOT", "TO", "BE"}
0
Returns: "QNO"
k = 0 means that you're not allowed to change any digits, so the answer is the sum of the given numbers.
{"KEQUALS36"}
36
Returns: "ZZZZZZZZZ"
k = 36 means that you have to replace all the letters with 'Z'.
{"GOOD", "LUCK", "AND", "HAVE", "FUN"}
7
Returns: "31YUB"
Submissions are judged against all 103 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class HexatridecimalSum with a public method string maximizeSum(vector<string> numbers, int k) · 103 test cases · 2 s / 256 MB per case