| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 49 | 23 | 19 | 57.576% |
Adrian is playing a game. When the game starts, Adrian will be given $P$ points as his initial points. The game consists of $N$ rounds, numbered from $1$ to $N$. During round $i$, Adrian has two options. Each option can be one of the following types:
+ $c$ ($-1000 ≤ c ≤ 1000$) which will add his current points by $c$, orx $c$ ($-2 ≤ c ≤ 2$) which will multiply his current points by $c$.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 $N$ rounds!
Input begins with two integers $N$ $P$ ($1 ≤ N ≤ 50$; $-1000 ≤ P ≤ 1000$) representing the number of rounds and the initial points during the game, respectively. Each of the next $N$ lines contains the two options in each round separated by a space. Each option is given in the format $T$ $c$ ($T ∈ \{$+, x$\}$; $-1000 ≤ c ≤ 1000$ if $T = $+, or $-2 ≤ c ≤ 2$ if $T = $x).
Output an integer in a single line representing the maximum points Adrian can achieve at the end of the game.
3 123 + 100 x 2 + -100 x -2 + 0 + 0
146
Adrian can choose the second option in round $1$, first option in round $2$, and any option in round $3$.
3 123 + 100 x 2 + -100 x -2 x 0 x 0
0
Adrian will always achieve $0$ points regardless of his decision in each round, because round $3$ will multiply his points by $0$.
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2022 G번