Problem I. Rikka with Bubble Sort
时间限制 1 ms
内存限制 512 MB
Bubble sort is a simple but beautiful algorithm. And this problem is a simple data structure task which is relative to bubble sort.
Rikka has an integer array $A$ of length $n$, and then she makes $m$ operations on it.
There are two types of operations:
1. 1 L R, Rikka runs the following C program on $A$.
for (int i=L;i<R;i++) if (A[i]>A[i+1]) swap(A[i], A[i+1]);
2. 2 L R, Rikka wants to know the interval sum of $[L,R]$, i.e., $\sum_{i=L}^R A_i$.
输入数据
输出数据
For each query, output a single line with a single integer, the answer.
样例输入
复制
5 6
1 5 4 5 1
1 3 5
2 2 4
1 2 4
2 1 3
1 1 5
2 3 4
样例输出
$ Mathjax font initiator $