{"trustable":false,"sections":[{"title":"题目描述","value":{"format":"MD","content":"**原题来自 USACO 2007 Jan. Gold**\n\nFJ 的 $N$ 头牛总是按同一序列排队。有一天,FJ 决定让一些牛玩一场飞盘比赛。他准备找一群在对列中为置连续的牛来进行比赛,但是为了避免水平悬殊,牛的身高不应该相差太大。FJ 准备了 $Q$ 个可能的牛的选择和所有牛的身高。他想知道每一组里面最高和最低的牛的身高差别。"}},{"title":"输入格式","value":{"format":"MD","content":"第一行:$N$ 和 $Q$; \n第二至第 $N+1$ 行,第 $i+1$ 行是第 $i$ 头牛的身高 $h_i$; \n第 $N+2$ 至第 $N+Q+1$ 行,每行两个整数 $A$ 和 $B$,表示从 $A$ 到 $B$ 的所有牛。"}},{"title":"输出格式","value":{"format":"MD","content":"第一至第 $Q$ 行,每行一个整数,表示对于询问的回答(即最高和最低的牛的身高差)。"}},{"title":"样例","value":{"format":"MD","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\u003e6 3\n1\n7\n3\n4\n2\n5\n1 5\n4 6\n2 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n3\n0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"数据范围与提示","value":{"format":"MD","content":"对于全部数据,$1\\le N\\le 5\\times 10^4,1\\le Q\\le 1.8\\times 10^2,1\\le h_i\\le 10^6,1\\le A\\le B\\le N$。"}}]}