Plus or Times
시간 제한1초메모리 제한2048 MB
N개의 라운드마다 주어진 두 연산(+c 또는 xc) 중 하나를 현재 점수에 적용하며, 마지막 점수를 최대로 만든다.
문제
Adrian is playing a game. When the game starts, Adrian will be given points as his initial points. The game consists of rounds, numbered from to . During round , Adrian has two options. Each option can be one of the following types:
+() which will add his current points by , orx() which will multiply his current points by .
Adrian wants to maximize his points at the end of the game. Help Adrian to determine the maximum points he can achieve after completing all rounds!
입력
Input begins with two integers (; ) representing the number of rounds and the initial points during the game, respectively. Each of the next lines contains the two options in each round separated by a space. Each option is given in the format (T ∈ \\{+, x\\}; if +, or if x).
출력
Output an integer in a single line representing the maximum points Adrian can achieve at the end of the game.