| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 45 | 21 | 17 | 58.621% |
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번