408831: GYM103347 A Ophelia's Happiness

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Ophelia's Happinesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Ophelia got asked out by Hamlet today! She is beyond jubilant and wants to celebrate. She goes to her personal garden and starts picking out roses for the occasion. Ophelia is curious about the total number of petals she has counted at certain points, and as such, starts counting the number of petals for each rose she picks. Unfortunately, Ophelia is quite poor at arithmetic, and wants you to help keep track of the total number of roses at any time.

Ophelia will give you a stream of queries of two types. The first type of query will be of the form $$$R\;c_i$$$, telling you that the $$$i^{th}$$$ rose has $$$c_i$$$ petals. The second type of query will be of the form $$$T$$$, where you must output the total number of petals.

Input

The first line will contain $$$n (1 \le n \le 10^5)$$$, the total number of queries that Ophelia has.

The next $$$n$$$ lines will each contain a query $$$R\;c_i$$$ (where $$$0 \le c_i \le 10^3$$$), or $$$T$$$.

Output

For every query $$$T$$$, output the total number of rose petals counted up to that point on a separate line.

ExampleInput
5
R 3
R 1
T
R 2
T
Output
4
6

加入题单

上一题 下一题 算法标签: