Score : $400$ points
At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:
Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.
The information Takahashi obtained is given as a string $T$. If the $i$-th character of $T$ $(1 \leq i \leq N)$ is r
, the machine will play Rock in the $i$-th round. Similarly, p
and s
stand for Paper and Scissors, respectively.
What is the maximum total score earned in the game by adequately choosing the hand to play in each round?
In this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.
r
, p
, and s
.Input is given from Standard Input in the following format:
$N$ $K$ $R$ $S$ $P$ $T$
Print the maximum total score earned in the game.
5 2 8 7 6 rsrpr
27
The machine will play {Rock, Scissors, Rock, Paper, Rock}.
We can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn $27$ points. We cannot earn more points, so the answer is $27$.
7 1 100 10 1 ssssppr
211
30 5 325 234 123 rspsspspsrpspsppprpsprpssprpsr
4996