QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#9124. 最大三角形

統計

有 $N$ 根直木棍,第 $i$ 根木棍的长度为 $L_i$。

考虑从中选出 3 根木棍组成一个(非退化的)三角形。请判断是否存在这样的组合,如果存在,计算能构成的三角形面积的最大值的平方。

共有 $T$ 组测试数据,请对每组数据进行回答。

输入格式

输入通过标准输入给出,格式如下。其中 $\text{case}_i$ 表示第 $i$ 组测试数据。

$T$ $\text{case}_1$ $\text{case}_2$ $\vdots$ $\text{case}_T$

每组测试数据的格式如下:

$N$ $L_1 \ L_2 \ \dots \ L_N$

  • 所有输入均为整数。
  • $1 \le T \le 2 \times 10^5$
  • $3 \le N \le 3 \times 10^5$
  • $2 \le L_i \le 20000$
  • $L_i$ 为偶数。
  • 对于每组输入,所有测试数据的 $N$ 之和不超过 $2 \times 10^5$。

输出格式

输出 $T$ 行。第 $i$ 行输出第 $i$ 组测试数据的答案。

对于每组测试数据,如果不存在合法的 3 根木棍组合,输出 -1。如果存在,输出能构成的三角形面积的最大值的平方。注意,在给定约束条件下,该值为整数。

样例

样例输入 1

3
5
2 2 2 2 2
7
2 6 4 10 8 10 20
5
4 16 36 64 100

样例输出 1

3
1344
-1

说明

在第 2 组测试数据中,边长为 8, 10, 10 的三角形面积最大,为 $8\sqrt{21}$。其平方为 1344。

在第 3 组测试数据中,无法选出 3 根木棍组成非退化三角形。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.