当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5196:DZY Loves Inversions

题目描述
DZY has a array $a$, consisting of $n$ positive integers, indexed from 1 to $n$.

Let's denote the number with index $i$ as $a_i$.

DZY wants to count, with a given pair ($l,r$)$(l\leq r)$, how many pairs of integers $i$ and $j$ are there, such that $l \leq i \leq j \leq r$ and the sequence $b=a_{i}a_{i+1}\cdots a_{j}$ has exactly $k$ inversions.

Moreover, DZY has $q$ queries.
输入解释
The input consists several test cases.($TestCase\leq 5$)

The first line contains three integers $n, q, k(1 \leq n \leq 10^5, 1 \leq q \leq 10^5, 0 \leq k \leq 10^{18})$.

The next line contains $n$ positive integers, separated by single spaces, $a_1,a_2,\cdots ,a_n(1 \leq a_i \leq 10^9)$.

Each of the next $q$ lines has two integers: $l,r$, representing a query.
输出解释
For each query, please print a line containing the answer.
输入样例
6 4 1
3 1 5 4 2 6
2 4
2 3
3 4
1 5
输出样例
2
0
1
5

提示
query 1. (2,4), (3,4) are ok.
query 2. No such pair. 
query 3. (3,4) is ok.
query 4. (1,2), (1,3), (2,4), (3,4), (4,5) are ok.
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #35

源链接: HDU-5196

最后修改于 2020-10-25T23:20:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 131072/131072K(Java/Others)