Hanbyeol's perfect sequence and query class
Time limit6sMemory limit1024 MB
Process an array with range chmin, chmax, and add updates, answering range min, max, and sum queries.
- Level
Medium6 of 10
- Topics
- Segment tree, Array
- Solved
- No attempts yet
Problem
Hanbyeol's sequence and query class is always known for its perfect lectures. But Hanbyeol is a fool, so even when given a sequence and query problem, he cannot write a program himself and hands the job to you every time. Solve the problem below in his place!
Given a sequence of length , write a program that processes the following queries.
- : For every , apply .
- : For every , apply .
- : For every , apply .
- : Print .
- : Print .
- : Print .
Note that the range of is not typical.
Input
The first line contains the size of the sequence . ()
The second line contains the integers , separated by spaces. ()
The third line contains the number of queries . ()
Each of the next lines contains one query. is an integer. (, )
Output
Print the results of queries 4, 5, and 6, one per line.
Hint
The statement of this problem may differ from Hanbyeol's original setting.