{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eChika 给出一个整数序列 $a_1, a_2, \\ldots, a_n$ 和 $m$ 个任务。对于每个任务,你需要回答在给定区间内的\"\u003cb\u003e友好对\u003c/b\u003e\"的数量。\u003cbr\u003e\u003cbr\u003e\u003cb\u003e友好对\u003c/b\u003e:对于两个整数 $a_i$ 和 $a_j$,如果 $i\u0026lt;j$ 且绝对值 $a_i-a_j$ 不超过给定的常数整数 $K$,那么 $(i, j)$ 被称为\"友好对\"。在区间 $[L,R]$ 中的友好对 $(i, j)$ 应满足 $L \\leq i \u0026lt; j \\leq R$。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"第一行包含 $3$ 个整数 $n$ $(1 \\leq n \\leq 27000)$,$m$ $(1 \\leq m \\leq 27000)$ 和 $K$ $(1 \\leq K \\leq 10^9)$,表示序列 $a$ 中的整数数量,任务数量和给定的常数整数。\u003cbr\u003e第二行包含 $n$ 个非负整数,表示序列 $a$ 中的整数。序列 $a$ 中的每个整数不超过 $10^9$。\u003cbr\u003e然后是 $m$ 行,每行包含两个整数 $L$,$R$ $(1 \\leq L \\leq R \\leq n)$。其含义是询问区间 $[L,R]$ 中的\"友好对\"数量。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个任务,你需要打印一行,只包含一个整数,表示查询区间中的\"友好对\"数量。"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7 5 3\r\n2 5 7 5 1 5 6\r\n6 6\r\n1 3\r\n4 6\r\n2 4\r\n3 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n2\r\n1\r\n3\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}