Problem F
Game Rank

Each rank has a certain number of “stars” that one needs to
gain before advancing to the next rank. If a player wins a
game, she gains a star. If before the game the player was on
rank
For instance, if before a winning game the player had all
the stars on her current rank, she will after the game have
gained one rank and have
If a player on rank
If a player reaches the Legend rank, she will stay legend no matter how many losses she incurs afterwards.
The number of stars on each rank are as follows:
-
Rank
- : stars -
Rank
- : stars -
Rank
- : stars -
Rank
- : stars
A player starts at rank
Input
The input consists of a single line describing the sequence
of matches. Each character corresponds to one game; ‘W’ represents a win and ‘L’ a loss. The length of the line is between
Output
Output a single line containing a rank after having played
the given sequence of games; either an integer between
Sample Input 1 | Sample Output 1 |
---|---|
WW |
25 |
Sample Input 2 | Sample Output 2 |
---|---|
WWW |
24 |
Sample Input 3 | Sample Output 3 |
---|---|
WWWW |
23 |
Sample Input 4 | Sample Output 4 |
---|---|
WLWLWLWL |
24 |
Sample Input 5 | Sample Output 5 |
---|---|
WWWWWWWWWLLWW |
19 |
Sample Input 6 | Sample Output 6 |
---|---|
WWWWWWWWWLWWL |
18 |