QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#3426. 工具栏中的图标

统计

Gunnar 对目前 LaTeX 可用的图形工具不满意,因此他正在开发自己的图形编辑器。他为每个编辑器功能都创建了一个正方形图标。这些图标将被放置在一个两行 $N$ 列的工具栏中。工具栏中每一行的高度等于该行中最大图标的尺寸。同样,每一列的宽度等于该列中最大图标的尺寸。工具栏的总高度是所有行高度之和,工具栏的总宽度是所有列宽度之和。Gunnar 现在想知道他应该如何排列这些图标,使得工具栏的面积尽可能小。

图 F.1:该工具栏的高度为 $100 + 3$,宽度为 $100 + 99 + 98$。总面积为 $(100 + 3) \cdot (100 + 99 + 98) = 30\,591$。此示例对应样例输入 1。

给定一个已排序的整数序列 $s_1, \dots, s_{2N}$,表示第 $i$ 个图标的尺寸为 $s_i \times s_i$。你的任务是计算一个两行 $N$ 列的工具栏所能达到的最小面积。

输入格式

输入的第一行包含一个整数 $N$,$1 \le N \le 1\,000\,000$。接下来的 $2N$ 行,每行包含一个整数 $s_i$,表示一个图标的尺寸。你可以假设 $1\,000\,000 \ge s_1 \ge s_2 \ge \dots \ge s_{2N} \ge 1$。

输出格式

输出一行,包含一个整数,即工具栏的最小可能面积。

样例

输入格式 1

3
100
99
98
3
2
1

输出格式 1

30591

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.