spoj#MON2012. Monkey and apples
Monkey and apples
Monkey Chris loves apples. That's why he has planted lots of apple trees. He does two types of operations on this trees.
- First operation "1 x y": means counting ripe apple trees on interval [x+c, y+c].
- Second operation "2 x y": means that all apples on interval [x+c, y+c] get ripe(edible).
C=0 in the beginning and becomes the answer of each query ("1" operation).
Input
Input begins with M (1 <= M <= 10^5) the number of operations. Afterwards M lines each of them is an operation ("1" or "2"). 1<=X+C; Y+C<=10^9.
Example
Input 3 2 5 8 2 7 10 1 1 10</p>Output 6
Explanation
3 queries. Apples gets ripe on intervals 5-8 and 7-10. There are totally 6 ripe apple-trees on interval 1-10 so answer to query is 6.