CF525C.Ilya and Sticks
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l__i.
Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that maximizes their total area. Each stick is used in making at most one rectangle, it is possible that some of sticks remain unused. Bending sticks is not allowed.
Sticks with lengths _a_1, _a_2, _a_3 and _a_4 can make a rectangle if the following properties are observed:
- _a_1 ≤ _a_2 ≤ _a_3 ≤ _a_4
- _a_1 = _a_2
- _a_3 = _a_4
A rectangle can be made of sticks with lengths of, for example, 3 3 3 3 or 2 2 4 4. A rectangle cannot be made of, for example, sticks 5 5 5 7.
Ilya also has an instrument which can reduce the length of the sticks. The sticks are made of a special material, so the length of each stick can be reduced by at most one. For example, a stick with length 5 can either stay at this length or be transformed into a stick of length 4.
You have to answer the question — what maximum total area of the rectangles can Ilya get with a file if makes rectangles from the available sticks?
晚上,比赛结束后,伊利亚感到十分无聊,他非常想让某个量最大化。他想起自己有一组 n 根木棍和一个工具。每根木棍由其长度 li 表征。
伊利亚决定用这些木棍制作矩形。出于一时兴起,他希望所制作的所有矩形的总面积最大。每根木棍最多只能用于制作一个矩形,部分木棍可以不使用。不允许弯曲木棍。
当且仅当以下条件全部满足时,长度分别为 a1,a2,a3 和 a4 的四根木棍可以构成一个矩形:
- a1 ≤ a2 ≤ a3 ≤ a4
- a1 = a2
- a3 = a4
例如,长度为 3,3,3,3 或 2,2,4,4 的四根木棍可以构成矩形;而长度为 5,5,5,7 的四根木棍则不能构成矩形。
此外,伊利亚还有一个工具,可以将木棍的长度减小。这些木棍由一种特殊材料制成,因此每根木棍的长度最多只能减少 1。例如,一根长度为 5 的木棍可以保持长度不变,也可以被加工成长度为 4 的木棍。
你需要回答的问题是:如果伊利亚使用该工具对木棍进行适当加工,并从所有可用木棍中制作矩形,那么他所能获得的矩形总面积的最大值是多少?
输入格式
The first line of the input contains a positive integer n (1 ≤ n ≤ 105) — the number of the available sticks.
The second line of the input contains n positive integers l__i (2 ≤ l__i ≤ 106) — the lengths of the sticks.
输入的第一行包含一个正整数 n(1 ≤ n ≤ 105)—— 可用木棍的数量。
输入的第二行包含 n 个正整数 li(2 ≤ li ≤ 106)—— 各木棍的长度。
输出格式
The first line of the output must contain a single non-negative integer — the maximum total area of the rectangles that Ilya can make from the available sticks.
输出的第一行必须包含一个非负整数——Ilya 能够利用现有木棍制作出的矩形的最大总面积。
输入输出样例
输入#1
4 2 4 4 2
输出#1
8
输入#2
4 2 2 3 5
输出#2
0
输入#3
4 100003 100004 100005 100006
输出#3
10000800015
输入解题思路,AI测评打分。不知道怎么写?