P27007 [AtCoder] Kaburin!
普及+
题目描述

Problem Description

Kaburin Image "Kaburin!" is an action RPG where you throw mysterious creatures called Kaburin, who wear bags on their heads, to defeat enemies.

Daiki, a passionate fan of Kaburin, decided to create a program to calculate the damage dealt to enemies.

The rules of the game are as follows:

At the start of the game, you have 5 bags of Kaburin.

You can throw the Kaburin in your hand to deal damage to enemies. The thrown Kaburin will return to your hand after a while.

There are two types of throws: "Normal Throw" and "Charged Throw". Each throw increases your combo count when it deals damage.

Normal Throw

  • Throws 1 bag of Kaburin.
  • Requires at least 1 bag of Kaburin in hand.
  • Takes 0.5 seconds to throw.
  • Deals damage 1 second after being thrown.
  • The base damage is 10, which increases based on the combo count.
  • Returns to hand 5 seconds after dealing damage.

Charged Throw

  • Throws 3 bags of Kaburin.
  • Requires at least 3 bags of Kaburin in hand.
  • Takes 2.5 seconds to throw, during which no other actions can be performed.
  • Deals damage 1 second after being thrown.
  • The base damage is 50, which increases based on the combo count.
  • Returns to hand 5 seconds after dealing damage.

Combo

  • The combo count starts at 0 at the beginning of the game.
  • Both Normal Throw and Charged Throw increase the combo count by 1 when they deal damage.
  • Every 10 combos increase the damage dealt by 10% of the base damage.
  • The damage dealt is calculated as \( A \times (1 + \text{floor}(C / 10) \times 0.1) \), where \( A \) is the base damage and \( C \) is the combo count.
  • \( \text{floor}(x) \) means the largest integer not greater than \( x \).
  • The increase in attack power applies to Kaburin thrown after achieving the combo.

User Input

  • Each second, the user inputs either Normal Throw, Charged Throw, or does nothing.
  • Throws are ignored if the required number of Kaburin is not available in hand.
  • Throws during the charging period are ignored.

Given the user's inputs, calculate the total damage dealt to the enemy.

Note that the damage from Kaburin that are thrown but not yet dealt at the end of the user's inputs should also be included in the calculation.

Input Format

Input is given from standard input in the following format:

\( S_1\ S_2\ \ldots\ S_n \)

  • A string of length \( n \) (\( 1 \leq n \leq 1000000 \)) representing the user's inputs is given in one line.
  • The \( i \)-th character \( S_i \) represents the user's input at the \( i \)-th second.
  • \( S_i \) can be one of the following:
  • - No input.
  • N Normal Throw.
  • C Charged Throw.

Output Format

Output the total damage dealt to the enemy as a single integer in one line.

Note that the line should end with a newline, and the total damage is guaranteed to be less than \( 10^{11} \).

Be aware that the total damage may not fit into a typical 32-bit integer type.

Sample Input and Output

Sample Input #1

NNNNNNNN

Sample Output #1

60

Sample Input #2

CCCCC

Sample Output #2

50

Sample Input #3

NNC------NNC------NNC------NNC------NNC------NNC

Sample Output #3

439

Notes/Hints

Sample Explanation 1

Daiki tries to throw Kaburin 8 times with Normal Throw, but there are no Kaburin in hand on the 6th and 7th seconds. On the 8th second, the Kaburin thrown on the 1st second returns, so he can throw 6 times, dealing 60 damage.

Sample Explanation 2

On the 1st second, Daiki starts a Charged Throw with 3 bags of Kaburin. The inputs on the 2nd and 3rd seconds are ignored because he is charging. The inputs on the 4th and 5th seconds are ignored because there are not enough Kaburin in hand.

Sample Explanation 3

The increase in damage due to combos applies not at the time of throwing but at the time of starting to charge. (Updated at 22:20) Note that the damage increase applies to Kaburin thrown after reaching 10 combos.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
NNNNNNNN
样例输出
60