MicrosoftOA #44
Maximum Sum After Merges
估计中等可在线判题
考点(AI 标注)动规入门
Two originally adjacent elements may be concatenated in decimal, but each original element can be used at most once, and a concatenated result cannot be concatenated again. Find the maximum possible sum of the final elements.
This site uses a standard input/output protocol.
输入格式
The first line contains N (1..10000), and the second line contains N integers in 0..200. 0 also takes up one digit, and concatenating 02 gives the value 2.
输出格式
Output a single integer, the answer.
样例 1
输入:
6
2 2 3 5 4 0
输出:
97
样例 2
输入:
5
3 19 191 91 3
输出:
20107
样例 3
输入:
3
0 0 1
输出:
1
样例说明
Example 1: 22+35+40=97. Example 2: keep 3 and form 19191 and 913, for a total of 20107. Example 3: 01 can be formed, but its value is still 1, so the maximum sum is 1.