CF1252H.Twin Buildings

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ithi^{th} land has a rectangular shape of size Li×WiL_i \times W_i. 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 \times B can be build on the ithi^{th} land if and only if at least one of the following is satisfied:

  • A≤LiA \le L_i and B≤WiB \le W_i, or
  • A≤WiA \le W_i and B≤LiB \le L_i.

Alternatively, it is also possible to build two buildings of A×BA \times B on the ithi^{th} land with the same orientation. Formally, it is possible to build two buildings of A×BA \times B on the ithi^{th} land if and only if at least one of the following is satisfied:

  • A×2≤LiA \times 2 \le L_i and B≤WiB \le W_i, or
  • A×2≤WiA \times 2 \le W_i and B≤LiB \le L_i, or
  • A≤LiA \le L_i and B×2≤WiB \times 2 \le W_i, or
  • A≤WiA \le W_i and B×2≤LiB \times 2 \le L_i.

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 \times B; output the largest possible for A×BA \times B.

你可能已经知道,场地空间一直是雅加达 ICPC 的一个难题。为了解决这个问题,雅加达 ICPC 计划建造两栋新大楼。这两栋大楼必须具有相同尺寸的矩形形状。现在,他们的难题是寻找合适的土地来建造这些建筑。

目前有 NN 块土地可供出售。第 ii 块土地呈矩形,尺寸为 Li×WiL_i \times W_i。为了良好的风水,建筑物的边必须与土地的边平行。

一种方案是将两栋建筑分别建在两块不同的土地上(每块土地上建一栋,且两栋建筑的朝向不一定相同)。尺寸为 A×BA \times B 的建筑可以建在第 ii 块土地上,当且仅当满足以下条件之一:

  • A≤LiA \le L_i 且 B≤WiB \le W_i,或者
  • A≤WiA \le W_i 且 B≤LiB \le L_i。

另一种方案是将两栋尺寸均为 A×BA \times B 的建筑建在同一块第 ii 块土地上,且朝向相同。形式化地说,能在第 ii 块土地上建造两栋尺寸为 A×BA \times B 的建筑,当且仅当满足以下条件之一:

  • A×2≤LiA \times 2 \le L_i 且 B≤WiB \le W_i,或者
  • A×2≤WiA \times 2 \le W_i 且 B≤LiB \le L_i,或者
  • A≤LiA \le L_i 且 B×2≤WiB \times 2 \le W_i,或者
  • A≤WiA \le W_i 且 B×2≤LiB \times 2 \le L_i。

本题的任务是帮助雅加达 ICPC 根据给定的 NN 块可用土地,找出所能建造的最大尺寸的建筑。注意:雅加达 ICPC 必须建造两栋尺寸均为 A×BA \times B 的建筑;请输出最大的可能的 A×BA \times B 值。

输入格式

Input begins with a line containing an integer: NN (1≤N≤100 0001 \le N \le 100\,000) representing the number of available lands. The next NN lines each contains two integers: LiL_i WiW_i (1≤Li,Wi≤1091 \le L_i, W_i \le 10^9) representing the size of the land.

输入的第一行包含一个整数:NN(1≤N≤100 0001 \le N \le 100\,000),表示可用土地的数量。接下来的 NN 行每行包含两个整数:LiL_i 和 WiW_i(1≤Li,Wi≤1091 \le L_i, W_i \le 10^9),表示第 ii 块土地的尺寸。

输出格式

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).

在一行中输出一个数字,表示 ICPC 雅加达团队能够建造的最高建筑的高度(精确到小数点后一位)(参见样例输入/输出以明确格式要求)。

输入输出样例

  • 输入#1

    2
    5 5
    3 4

    输出#1

    12.5
  • 输入#2

    2
    2 5
    4 3

    输出#2

    8.0
  • 输入#3

    3
    10 1
    9 8
    7 6

    输出#3

    42.0

说明/提示

Explanation for the sample input/output #1

Two buildings of 2.5×52.5 \times 5 can be built both on the first land.

Explanation for the sample input/output #2

Two buildings of 2×42 \times 4 can be built each on the first and second lands.

Explanation for the sample input/output #3

Two buildings of 7×67 \times 6 can be built each on the second and third lands.

样例输入/输出 #1 的说明

两个 2.5×52.5 \times 5 的建筑物均可建在第一块土地上。

样例输入/输出 #2 的说明

一个 2×42 \times 4 的建筑物可建在第一块土地上,另一个 2×42 \times 4 的建筑物可建在第二块土地上。

样例输入/输出 #3 的说明

一个 7×67 \times 6 的建筑物可建在第二块土地上,另一个 7×67 \times 6 的建筑物可建在第三块土地上。

输入解题思路,AI测评打分。不知道怎么写?

首页