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

建议使用的浏览器:

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

6534:Chika and Friendly Pairs

题目描述
Chika gives you an integer sequence $a_1, a_2, \ldots, a_n$ and $m$ tasks. For each task, you need to answer the number of "friendly pairs" in a given interval.

friendly pair: for two integers $a_i$ and $a_j$, if $i<j$ and the absolute value of $a_i-a_j$ is no more than a given constant integer $K$, then $(i, j)$ is called a "friendly pair".A friendly pair $(i, j)$ in a interval $[L,R]$ should satisfy $L \leq i < j \leq R$.
输入解释
The first line contains $3$ integers $n$ $(1 \leq n \leq 27000)$, $m$ $(1 \leq m \leq 27000)$ and $K$ $(1 \leq K \leq 10^9)$, representing the number of integers in the sequence $a$, the number of tasks and the given constant integer.
The second line contains $n$ non-negative integers, representing the integers in the sequence $a$. Every integer of sequence $a$ is no more than $10^9$.
Then $m$ lines follow, each of which contains two integers $L$, $R$ $(1 \leq L \leq R \leq n)$. The meaning is to ask the number of "friendly pairs" in the interval $[L,R]$。
输出解释
For each task, you need to print one line, including only one integer, representing the number of "friendly pairs" in the query interval.
输入样例
7 5 3
2 5 7 5 1 5 6
6 6
1 3
4 6
2 4
3 4
输出样例
0
2
1
3
1
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6534

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

共提交 0

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