#Lutece2540. 区间逆序对
区间逆序对
Migrated from Lutece 2540 区间逆序对
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
数列 的一组逆序对是指一对位置 满足 但 。例如 的逆序对数量为 ,满足条件的 分别是 。
一个数列 的子区间 是指数列 。
现在给定一个数列 ,请求出他的多个子区间的逆序对数量。
Input
第一行两个正整数 ,分别表示数列长度和子区间个数。
第二行 个正整数,第 个数表示 。
接下来 行,每行两个正整数 表示一个子区间 。
Output
行,每行一个正整数,表示子区间的逆序对数量。
Samples
3 2
3 1 2
1 2
1 3
1
2
Constraints
$1 \leq n,m \leq 2\times 10^5,1\le a_i\le n,1\le l\le r\le n$
Note
请注意 并不保证是一个排列。
Resources
2021 UESTC ICPC Training for Data Structures