CF1398D.Colored Rectangles
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three multisets of pairs of colored sticks:
- R pairs of red sticks, the first pair has length r1, the second pair has length r2, …, the R-th pair has length rR;
- G pairs of green sticks, the first pair has length g1, the second pair has length g2, …, the G-th pair has length gG;
- B pairs of blue sticks, the first pair has length b1, the second pair has length b2, …, the B-th pair has length bB;
You are constructing rectangles from these pairs of sticks with the following process:
- take a pair of sticks of one color;
- take a pair of sticks of another color different from the first one;
- 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?
你有三组彩色木棍对(多重集):
- R 对红色木棍,第 1 对长度为 r1,第 2 对长度为 r2,…,第 R 对长度为 rR;
- G 对绿色木棍,第 1 对长度为 g1,第 2 对长度为 g2,…,第 G 对长度为 gG;
- B 对蓝色木棍,第 1 对长度为 b1,第 2 对长度为 b2,…,第 B 对长度为 bB;
你将使用这些木棍对按如下过程构造矩形:
- 选取一种颜色的一对木棍;
- 选取另一种(与第一步颜色不同)颜色的一对木棍;
- 将由此构成的矩形面积加到总面积中。
因此,所构造的矩形满足:对边颜色相同,邻边颜色不同。
每对木棍最多只能使用一次,部分木棍对可以不使用。不允许将一对木棍拆分为两根独立的木棍。
你能获得的最大总面积是多少?
输入格式
The first line contains three integers R, G, B (1≤R,G,B≤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 r1,r2,…,rR (1≤ri≤2000) — the lengths of sticks in each pair of red sticks.
The third line contains G integers g1,g2,…,gG (1≤gi≤2000) — the lengths of sticks in each pair of green sticks.
The fourth line contains B integers b1,b2,…,bB (1≤bi≤2000) — the lengths of sticks in each pair of blue sticks.
第一行包含三个整数 R、G、B(1≤R,G,B≤200)——分别表示红色木棍的对数、绿色木棍的对数以及蓝色木棍的对数。
第二行包含 R 个整数 r1,r2,…,rR(1≤ri≤2000)——表示每对红色木棍中木棍的长度。
第三行包含 G 个整数 g1,g2,…,gG(1≤gi≤2000)——表示每对绿色木棍中木棍的长度。
第四行包含 B 个整数 b1,b2,…,bB(1≤bi≤2000)——表示每对蓝色木棍中木棍的长度。
输出格式
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×5=20.
In the second example the best rectangles are: red/blue 9×8, red/blue 5×5, green/blue 2×1. So the total area is 72+25+2=99.
In the third example the best rectangles are: red/green 19×8 and red/blue 20×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.
在第一个例子中,你可以构造以下矩形之一:红色与绿色组成的边长为 3 和 5 的矩形、红色与蓝色组成的边长为 3 和 4 的矩形、绿色与蓝色组成的边长为 5 和 4 的矩形。其中面积最大的是 4×5=20。
在第二个例子中,最优的矩形为:红色/蓝色 9×8、红色/蓝色 5×5、绿色/蓝色 2×1。因此总面积为 72+25+2=99。
在第三个例子中,最优的矩形为:红色/绿色 19×8 和红色/蓝色 20×11。总面积为 152+220=372。注意,你无法构造更多矩形,因为不允许两对矩形使用相同的颜色组合。
输入解题思路,AI测评打分。不知道怎么写?