#P8683. [蓝桥杯 2019 省 B] 后缀表达式
[蓝桥杯 2019 省 B] 后缀表达式
Description
Given plus signs, minus signs, and integers , Xiaoming wants to know which legal postfix expression formed by these plus signs, minus signs, and integers has the maximum value.
Please output this maximum value.
For example, using 1 2 3 + -, the postfix expression 2 3 + 1 - has value , which is the maximum.
Input Format
The first line contains two integers and .
The second line contains integers .
Output Format
Output one integer, which is the answer.
1 1
1 2 3
4
Hint
For all test cases, , .
Lanqiao Cup 2019 Provincial Contest Group B, Problem I.
Translated by ChatGPT 5
京公网安备 11011102002149号