#P9987. [Ynoi2079] riapq
[Ynoi2079] riapq
Problem Description
Given a permutation , you need to maintain a sequence , with initial values .
There are operations in total:
- Update operation: given , for every pair satisfying , increase by .
- Query operation: given , query .
Input Format
The first line contains two integers .
The second line contains integers representing in order.
The next lines each contain either or , representing an update operation or a query operation.
All numbers in the input are integers.
Output Format
For each query operation, output one line containing one integer, which is the answer.
8 10
5 4 8 7 1 6 3 2
1 2 5
2 8
1 2 8
1 7 8
2 4
2 1
2 6
2 4
1 8 8
2 4
0
4
0
3
4
4
Hint
Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
For of the testdata, it holds that:
.
, and all are distinct.
.
.
Translated by ChatGPT 5