Logo
(追記) (追記ここまで)

33086번 - Plus or Times 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB45211758.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,ドル or
  • x $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.

제한

예제 입력 1

3 123
+ 100 x 2
+ -100 x -2
+ 0 + 0

예제 출력 1

146

Adrian can choose the second option in round 1ドル,ドル first option in round 2ドル,ドル and any option in round 3ドル$.

예제 입력 2

3 123
+ 100 x 2
+ -100 x -2
x 0 x 0

예제 출력 2

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번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /