|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||19||3||3||25.000%|
Edo spends most of his time in garden lately. There he cultivates, is mowing, irrigates, fertilizes and extents his grass and happily watches how it grow.
He is mowing the grass by specific rules every few days. On the other side, grass grows every day for the same length, but has limit of H millimeters in height (at this point every plant consumes too much food and cannot grow no more). When the time for fertilizing arrives, Edo has to calculate what the necessary amount of compost is. Optimal amount of compost depends on the amount of grass.
Precisely, his garden can be represented as one-dimensional array of exactly N plants of grass with height equal to zero at the beginning. It is necessary to write a program which calculates the sum of height of all grass plants whenever it is needed for Edo.
Write a program which reads and evaluates M operations on Edo’s garden. Every operation is one of the following:
First line of input contains three positive integer numbers N, H and M (1 ≤ N ≤ 109, 1 ≤ H ≤ 106, 1 ≤ M ≤ 106) – number of grass plants, maximal height of plants and number of operations. Next M lines of input contain description of one operation. Every operation is one of five previously described operations and is made of one capital letter and integer number (if necessary – operations N, L, D, S) X separated with one space. In operations L and D number X will be in interval 1 ≤ X ≤ N, and in case of operations N and S number X will be in interval 1 ≤ X ≤ H.
For every operation Z it is necessary to write one line with one integer – sum of heights of all grass plants. Of course, order of responses has to be the same as the order of Z operations in input.
Note: sum of heights can be larger than 232.
10 1000 5 Z N 10 Z L 3 Z
0 100 70
10 1000 10 N 10 L 5 Z N 10 L 3 Z D 2 Z S 1 Z
50 120 80 5
7 10 10 N 9 Z N 9 Z N 5 Z S 1 Z N 10 Z
63 70 70 7 70