#P2801. 教主的魔法
教主的魔法
Description
{{The leader has recently learned a magical spell that can make people taller. He plans to demonstrate it to every hero in the XMYZ Information Group. Thus, heroes gather once again, lining up in a row and being numbered .
Each person’s height is initially a positive integer not exceeding . Each time the leader casts the spell, he can add an integer to the heights of all heroes in the closed interval (). (Although is not standard interval notation, we can regard it as increasing only the height of the -th hero.)
CYZ, Guang Ge, and ZJQ do not believe in the leader’s magic, so they sometimes ask WD how many heroes in the closed interval have height greater than or equal to , to verify whether the magic really works.
WD is extremely lazy, so he hands this task over to you.}}
Input Format
{{The first line contains two integers . is the total number of queries and spells.
The second line contains positive integers; the -th number is the height of the -th hero.
Lines through each contain one operation:
-
If the first letter is
M, then three numbers follow. Add to the heights of all heroes in the closed interval . -
If the first letter is
A, then three numbers follow. Query how many heroes in the closed interval have height greater than or equal to .}}
Output Format
{{For each A query, output one line containing a single integer: the number of heroes with height greater than or equal to in .}}
5 3
1 2 3 4 5
A 1 5 4
M 3 5 1
A 1 5 4
2
3
Hint
{{Sample explanation:
Originally, the heroes’ heights are , so there are heroes in whose heights are at least . After the leader casts the spell, the heights become , so there are heroes in whose heights are at least .
Constraints:
- For of the testdata, , .
- For of the testdata, , , , .
: A new set of Hack testdata has been added. : A new set of Hack testdata has been added.}}
Translated by ChatGPT 5
京公网安备 11011102002149号