You are given an array , , , , consisting of integers, as well as integers and . The following operation is performed times on the array:
For from to , let denote the value of the -th order statistic in the array obtained from after applying the operation times with the given parameter . For from to , the -th order statistic of the array is the element that would be in position if the array were sorted in non-decreasing order.
For all such that , let denote the sum of for all integers from to . More formally:
You are given integers and . You must compute the values of for all from to .
After that, you must process queries. The -th query () can be one of three types:
All calculations of the functions and are performed independently each time and do not change the array. All changes to the array in queries of the second type are preserved for subsequent queries.
The first line contains four integers , , , and (, , , ) --- the length of the array ; the number of operations; the number of largest elements decreased in each operation, and the number of queries.
The second line contains integers (, ) --- the elements of the array .
The next lines contain the queries. In the -th query, the first number is () --- the type of the -th query.
In the first line, output integers .
Then, for each first type query, output the value on a separate line, and for each third type query, output the value ~--- the answer to the -th query.
8 3 2 16
3 1 2 -1 0 2 -1 4
3 3 2 2 6
1 3 2 4
3 4 5 3 5
1 4 5 6
2 5 -1
2 6 3
1 3 2 1
1 3 2 3
1 3 2 4
1 3 2 8
1 0 5 6
2 1 5
3 1 3 7 8
3 2 3 5 8
3 3 3 4 7
3 4 3 4 7
-1 -1 0 1 1 1 1 2
2
1
-4
-1
-1
-1
1
2
3
7
8
4
2
In the example, , , , . Initially, the array is . Let's see how the array will change if we apply the operation times with parameter :
We find that after applying the operation times with parameter to the array , it becomes . If this array is sorted, it results in the array . Thus, the order statistics are , , , , , , , .
In the example, we need to process queries; let's analyze the first of them in detail:
Scoring
The tests for this problem consist of eleven groups. Points for each group are given only if all tests of the group and all tests of the required groups are passed. Please note that passing the example tests is not required for some groups. means that the results of testing your solution on this group will only be available after the end of the competition.
If there are constraints on or in a subtask, they apply to both and , as well as to the parameters of all first and third type queries.
| Group | Points | Additional constraints: | Required Groups | Comment | |||
|---|---|---|---|---|---|---|---|
| 0 | -- | -- | -- | -- | Examples. | ||
| 1 | 4 | -- | |||||
| 2 | 5 | -- | -- | ||||
| 3 | 6 | 2 | for all queries | ||||
| 4 | 7 | 2, 3 | for all queries | ||||
| 5 | 11 | -- | -- | ||||
| 6 | 9 | -- | 1 | ||||
| 7 | 10 | -- | |||||
| 8 | 7 | -- | 1, 2, 5 -- 7 | ||||
| 9 | 11 | 1 -- 3, 5 -- 8 | for all queries | ||||
| 10 | 13 | 1 -- 3, 5 -- 9 | for all queries | ||||
| 11 | 9 | 0 -- 10 | -- | ||||
| 12 | 8 | -- | 0 -- 11 | Offline-evaluation. | |||