#P1388. 算式
算式
Description
Given numbers, without changing their relative order, insert multiplication signs and plus signs between them. Parentheses can be added arbitrarily to maximize the final result. Since the total number of operators is , there is exactly one operator between every pair of adjacent numbers. For example:
When , , and the numbers are , , , , , you can form:
Input Format
The first line contains two integers separated by a space, denoting and .
The second line contains space-separated integers , representing the given numbers.
Output Format
Output a single line containing one integer, the maximum possible result.
5 2
1 2 3 4 5
120
Hint
Constraints
- For of the testdata, it is guaranteed that , , , and the answer is less than .
Translated by ChatGPT 5
京公网安备 11011102002149号