АВТ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

14. Expression

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added debug

Дано правильное арифметическое выражение, содержащее целые числа и знаки '+' и '-'. Определить, какое минимальное и максимальное значение выражения можно получить путем расстановки в нём скобок.

Input

Входная строка представляет собой правильное арифметическое выражение, содержащее целые числа в диапазоне от 0 до 1000 включительно и знаки '+' и '-'. Количество чисел в выражении не превышает 100.

Output

Выведите два целых числа - минимально и максимально возможное значение выражения после расстановки скобок.

Sample

InputOutput
2+1-3-5-5 5

View Problem Statistics Submit Problem discussion Author/source:
Sorted Problems / Dynamic programming, recurrent relations /
68. Equation with Missing Digits 14. 12. FastFood 10. Folding 867. Heap of Stones - 1
Problems from Contests and Camps / VoSU Selection Rounds / Selection Round on ACM ICPC 2004 /
13. A - Inversions 14. 15. C - Factorials 16. D - Polygon and Point
Educational Courses / Algorithms and Data Structures / Enumeration, Dynamic Programming, Greedy algs /
294. Dragons 14. 1184. Game with chips 2154. Heap of Stones - 2 1182. Heap of stones - 3
Problems from Contests and Camps / School olympiads and couses of Vologda region / Impulse - 2019 / Dynamic Programming /
843. 05 - Domenojgi 14. 1717. 07 - Increasing Subsequence 870. 08 - Pile of Stones - 2 901. 09 - Boxes
Problems from Contests and Camps / School olympiads and couses of Vologda region / Impulse, september 2020 / Impulse-2020, DP /
1493. 05 - How to Get One 14. 867. 07 - Heap of Stones - 1 870. 08 - Pile of Stones - 2 12. 09 - FastFood
time generating 0.094 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.