Operations
Time limit1sMemory limit128 MB
Maintain an array of values below k under interval cyclic increments and answer interval sums.
- Level
Medium6 of 10
- Topics
- Segment tree
- Solved
- No attempts yet
Problem
You are given a sequence of integers , where every element lies in the range . Perform operations of the following two kinds on this sequence.
- Report the range sum .
- Replace every with by .
Input
The first line contains three integers , , and (, , ). The second line contains integers describing the sequence ().
Each of the next lines describes one operation. Each line begins with an integer giving the operation type. If , it is a range-sum query and is followed by two integers and . If , it is a range-update operation and is followed by three integers , , and (, ).
Output
For each range-sum operation, print the computed result on its own line.