307696: CF1398D. Colored Rectangles

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Colored Rectangles

题意翻译

你手里有3套不同颜色的**木棍对(pair)**,包括: - $R$ 对红色的棍子,第 $i$ 对的两根木棍长度均为 $r_i$; - $G$ 对绿色的棍子,第 $i$ 对的两根木棍长度均为 $g_i$; - $B$ 对蓝色的棍子,第 $i$ 对的两根木棍长度均为 $b_i$; 现在你要按照如下步骤构造长方形: 1. 选择任意一种颜色的任意一对木棍; 2. 选择任意一种**不同颜色**的任意一对木棍; 3. 将木棍摆成长方形,使得对边木棍的颜色相同,邻边木棍的颜色不同。计第 $i$ 个构造出的长方形的面积为 $S_i$。 注意:每一堆木棍只能使用 $1$ 次,你不必使用每一堆木棍。 若 $s$ 为你构造出的长方形的总数,请你计算: $$\max \sum_{i=1}^s S_i$$

题目描述

You are given three multisets of pairs of colored sticks: - $ R $ pairs of red sticks, the first pair has length $ r_1 $ , the second pair has length $ r_2 $ , $ \dots $ , the $ R $ -th pair has length $ r_R $ ; - $ G $ pairs of green sticks, the first pair has length $ g_1 $ , the second pair has length $ g_2 $ , $ \dots $ , the $ G $ -th pair has length $ g_G $ ; - $ B $ pairs of blue sticks, the first pair has length $ b_1 $ , the second pair has length $ b_2 $ , $ \dots $ , the $ B $ -th pair has length $ b_B $ ; You are constructing rectangles from these pairs of sticks with the following process: 1. take a pair of sticks of one color; 2. take a pair of sticks of another color different from the first one; 3. add the area of the resulting rectangle to the total area. Thus, you get such rectangles that their opposite sides are the same color and their adjacent sides are not the same color. Each pair of sticks can be used at most once, some pairs can be left unused. You are not allowed to split a pair into independent sticks. What is the maximum area you can achieve?

输入输出格式

输入格式


The first line contains three integers $ R $ , $ G $ , $ B $ ( $ 1 \le R, G, B \le 200 $ ) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $ R $ integers $ r_1, r_2, \dots, r_R $ ( $ 1 \le r_i \le 2000 $ ) — the lengths of sticks in each pair of red sticks. The third line contains $ G $ integers $ g_1, g_2, \dots, g_G $ ( $ 1 \le g_i \le 2000 $ ) — the lengths of sticks in each pair of green sticks. The fourth line contains $ B $ integers $ b_1, b_2, \dots, b_B $ ( $ 1 \le b_i \le 2000 $ ) — the lengths of sticks in each pair of blue sticks.

输出格式


Print the maximum possible total area of the constructed rectangles.

输入输出样例

输入样例 #1

1 1 1
3
5
4

输出样例 #1

20

输入样例 #2

2 1 3
9 5
1
2 8 5

输出样例 #2

99

输入样例 #3

10 1 1
11 7 20 15 19 14 2 4 13 14
8
11

输出样例 #3

372

说明

In the first example you can construct one of these rectangles: red and green with sides $ 3 $ and $ 5 $ , red and blue with sides $ 3 $ and $ 4 $ and green and blue with sides $ 5 $ and $ 4 $ . The best area of them is $ 4 \times 5 = 20 $ . In the second example the best rectangles are: red/blue $ 9 \times 8 $ , red/blue $ 5 \times 5 $ , green/blue $ 2 \times 1 $ . So the total area is $ 72 + 25 + 2 = 99 $ . In the third example the best rectangles are: red/green $ 19 \times 8 $ and red/blue $ 20 \times 11 $ . The total area is $ 152 + 220 = 372 $ . Note that you can't construct more rectangles because you are not allowed to have both pairs taken to be the same color.

Input

题意翻译

你手里有3套不同颜色的**木棍对(pair)**,包括: - $R$ 对红色的棍子,第 $i$ 对的两根木棍长度均为 $r_i$; - $G$ 对绿色的棍子,第 $i$ 对的两根木棍长度均为 $g_i$; - $B$ 对蓝色的棍子,第 $i$ 对的两根木棍长度均为 $b_i$; 现在你要按照如下步骤构造长方形: 1. 选择任意一种颜色的任意一对木棍; 2. 选择任意一种**不同颜色**的任意一对木棍; 3. 将木棍摆成长方形,使得对边木棍的颜色相同,邻边木棍的颜色不同。计第 $i$ 个构造出的长方形的面积为 $S_i$。 注意:每一堆木棍只能使用 $1$ 次,你不必使用每一堆木棍。 若 $s$ 为你构造出的长方形的总数,请你计算: $$\max \sum_{i=1}^s S_i$$

加入题单

上一题 下一题 算法标签: