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

建议使用的浏览器:

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

6601:Keen On Everything But Triangle

题目描述
$N$ sticks are arranged in a row, and their lengths are $a_1, a_2, ... , a_N$.

There are $Q$ querys. For $i$-th of them, you can only use sticks between $l_i$-th to $r_i$-th. Please output the maximum circumference of all the triangles that you can make with these sticks, or print $-1$ denoting no triangles you can make.
输入解释
There are multiple test cases.

Each case starts with a line containing two positive integers $N,Q(N, Q \leq 10^5)$.

The second line contains $N$ integers, the $i$-th integer $a_i(1 \leq a_i \leq 10^9)$ of them showing the length of the $i$-th stick.

Then follow $Q$ lines. $i$-th of them contains two integers $l_i, r_i(1 \leq l_i \leq r_i \leq N)$, meaning that you can only use sticks between $l_i$-th to $r_i$-th.

It is guaranteed that the sum of $N$s and the sum of $Q$s in all test cases are both no larger than $4 \times 10^5$.
输出解释
For each test case, output $Q$ lines, each containing an integer denoting the maximum circumference.
输入样例
5 3
2 5 6 5 2
1 3
2 4
2 5
输出样例
13
16
16
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6601

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

共提交 0

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