A - イベント払い戻し 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 233

問題文

高橋君は、とあるイベント会場の受付で働いています。このイベントでは、チケットの種類として一般チケット学割チケット2 種類を販売しています。

ある日、イベントの一部プログラムが中止になったため、来場者に対してチケット代金を払い戻すことになりました。払い戻しのルールは以下の通りです。

  • 一般チケット(入力では normal と表記)を持っている来場者には、その来場者の購入金額 P_i 円の全額、すなわち P_i 円を払い戻す。
  • 学割チケット(入力では half と表記)を持っている来場者には、その来場者の購入金額 P_i 円の半額(小数点以下切り捨て)、すなわち \lfloor P_i / 2 \rfloor 円を払い戻す。

高橋君のもとに N 人の来場者が払い戻しの列に並んでいます。各来場者 i (1 \leq i \leq N) について、チケットの種類を表す文字列 T_i と購入金額 P_i (円)が与えられます。

高橋君が全員に払い戻す合計金額(円)を求めてください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • T_inormal または half のいずれかである。
  • 1 \leq P_i \leq 10^5
  • N および P_i はすべて整数である。

入力

N
T_1 P_1
T_2 P_2
\vdots
T_N P_N

1 行目には、来場者の人数を表す整数 N が与えられる。

続く N 行のうち i 行目 (1 \leq i \leq N) には、i 番目の来場者のチケットの種類を表す文字列 T_i と購入金額を表す整数 P_i (円)がスペース区切りで与えられる。

出力

高橋君が全員に払い戻す合計金額(円)を整数で 1 行に出力せよ。


入力例 1

3
normal 1000
half 500
half 300

出力例 1

1400

入力例 2

5
normal 2000
half 1999
normal 500
half 750
normal 1200

出力例 2

5074

入力例 3

10
normal 100000
half 99999
normal 50000
half 1
normal 12345
half 67890
normal 1
half 100000
normal 99999
half 55555

出力例 3

424066

Score : 233 pts

Problem Statement

Takahashi is working at the reception desk of a certain event venue. For this event, two types of tickets are sold: regular tickets and student discount tickets.

One day, part of the event program was canceled, so it was decided to refund the ticket prices to the visitors. The refund rules are as follows:

  • For visitors holding a regular ticket (denoted as normal in the input), the full amount of their purchase price P_i yen is refunded, i.e., P_i yen.
  • For visitors holding a student discount ticket (denoted as half in the input), half of their purchase price (rounded down) is refunded, i.e., \lfloor P_i / 2 \rfloor yen.

There are N visitors lined up for refunds at Takahashi's counter. For each visitor i (1 \leq i \leq N), a string T_i representing the ticket type and the purchase price P_i (in yen) are given.

Find the total amount (in yen) that Takahashi needs to refund to all visitors.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • T_i is either normal or half.
  • 1 \leq P_i \leq 10^5
  • N and all P_i are integers.

Input

N
T_1 P_1
T_2 P_2
\vdots
T_N P_N

The first line contains an integer N representing the number of visitors.

In the following N lines, the i-th line (1 \leq i \leq N) contains a string T_i representing the ticket type of the i-th visitor and an integer P_i representing the purchase price (in yen), separated by a space.

Output

Output the total refund amount (in yen) that Takahashi needs to pay to all visitors, as an integer on a single line.


Sample Input 1

3
normal 1000
half 500
half 300

Sample Output 1

1400

Sample Input 2

5
normal 2000
half 1999
normal 500
half 750
normal 1200

Sample Output 2

5074

Sample Input 3

10
normal 100000
half 99999
normal 50000
half 1
normal 12345
half 67890
normal 1
half 100000
normal 99999
half 55555

Sample Output 3

424066