2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings
2021-03-21 11:23
标签:icp task long iostream ast 面积 ril nes name As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC Jakarta is planning to build two new buildings. These buildings should have a shape of a rectangle of the same size. Now, their problem is to find land to build the buildings. There are NN lands available for sale. The ithith land has a rectangular shape of size Li×WiLi×Wi. For a good feng shui, the building‘s side should be parallel to the land‘s sides. One way is to build the two buildings on two different lands, one on each land (not necessarily with the same orientation). A building of size A×BA×B can be build on the ithith land if and only if at least one of the following is satisfied: A≤LiA≤Li and B≤WiB≤Wi, or A×2≤LiA×2≤Li and B≤WiB≤Wi, or Input Input begins with a line containing an integer: NN (1≤N≤1000001≤N≤100000) representing the number of available lands. The next NN lines each contains two integers: LiLi WiWi (1≤Li,Wi≤1091≤Li,Wi≤109) representing the size of the land. Output Output in a line a number representing the largest building that ICPC Jakarta can build with exactly one decimal point (see sample input/output for clarity). Examples input Copy 2 Copy 12.5 Copy 2 Copy 8.0 Copy 3 Copy 42.0 Explanation for the sample input/output #1 Two buildings of 2.5×5 can be built both on the first land. Explanation for the sample input/output #2 Two buildings of 2×4 can be built each on the first and second lands. Explanation for the sample input/output #3 Two buildings of 7×6 can be built each on the second and third lands. 解题思路:建造两块场地,使得两块场地的面积尽可能地大,有两种情况,第一种:取一块最大的土地,一分为二。第二种:对土地的长(x)进行排序,从大到小,面积取当前x与min(之前y的最大值,当前y的值)乘积作为一块的面积,那在当前x之前的x都大于当前x,所以必定也能放得下这一块面积。有个细节问题是土地的长可以宽,宽也可以是长,所以当宽>长时,需要交换值。注意精度问题,用long long存。 AC代码: 2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings 标签:icp task long iostream ast 面积 ril nes name 原文地址:https://www.cnblogs.com/lovelcy/p/11824421.html
A≤WiA≤Wi and B≤LiB≤Li.
Alternatively, it is also possible to build two buildings of A×BA×B on the ithith land with the same orientation. Formally, it is possible to build two buildings of A×BA×B on the ithith land if and only if at least one of the following is satisfied:
A×2≤WiA×2≤Wi and B≤LiB≤Li, or
A≤LiA≤Li and B×2≤WiB×2≤Wi, or
A≤WiA≤Wi and B×2≤LiB×2≤Li.
Your task in this problem is to help ICPC Jakarta to figure out the largest possible buildings they can build given NN available lands. Note that ICPC Jakarta has to build two buildings of A×BA×B; output the largest possible for A×BA×B.
5 5
3 4
output
input
2 5
4 3
output
input
10 1
9 8
7 6
output
Note#include
文章标题:2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings
文章链接:http://soscw.com/index.php/essay/67142.html