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≤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≤LiA×2≤Li and B≤WiB≤Wi, or
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.

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
5 5
3 4
output

Copy

12.5
input

Copy

2
2 5
4 3
output

Copy

8.0
input

Copy

3
10 1
9 8
7 6
output

Copy

42.0
Note

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代码:

#include <iostream>
#include <algorithm>
using namespace std;
struct Point{
long long x,y;
}point[];
bool cmp(Point a,Point b)
{
return a.x*a.y>b.x*b.y;
}
int main()
{
int n;
while(cin>>n)
{
long long area=;
for(int i=;i<n;i++)
{
cin>>point[i].x;
cin>>point[i].y;
area=max(point[i].x*point[i].y,area);
if(point[i].y>point[i].x)
swap(point[i].y,point[i].x);
}
long long maxy=;
sort(point,point+n,cmp);
for(int i=;i<n;i++)
{
area=max(area,point[i].x*min(point[i].y,maxy)*);
maxy=max(point[i].y,maxy);
}
if(area%)
cout<<area/<<".5"<<endl;
else
cout<<area/<<".0"<<endl;
}
return ;
}

最新文章

  1. Storm可靠性实例解析——ack机制
  2. Node.js 快速了解
  3. 第五周PSP
  4. c#中匿名函数lamb表达式
  5. mysql死锁,等待资源,事务锁,Lock wait timeout exceeded; try restarting transaction解决
  6. php 出现 500 Internal Server Error错误问题解决
  7. Linux开机启动(bootstrap)上
  8. 百度BAE环境搭建
  9. Mysql的JDBC
  10. Axure的中继器如何实现两个列表之间的交互
  11. react-redux笔记
  12. Spring中利用applicationContext.xml文件实例化对象和调用方法
  13. With As 用法
  14. python 模块之-time
  15. Pleasant sheep and big big wolf HDU - 3046(最小割)
  16. nginx传世经典
  17. Centos6安装FreeSWITCH 1.5时./configure问题解决记录
  18. 嵌入式开发板LInux更新系统、安装软件、下载资源碰到的问题
  19. Java并发编程:Lock和Synchronized &lt;转&gt;
  20. HUD 1175 连连看

热门文章

  1. PLSQL打开文件中文出现乱码
  2. 【细谈Java并发】谈谈LinkedBlockingQueue(转)
  3. @GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping、@RequestMapping详解
  4. 如何在 Laravel 中灵活的使用 Trait
  5. hdu 3555 Bomb(数位dp入门)
  6. 发布web项目时,关于未能加载文件或程序集或它的某一个依赖项。拒绝访问的问题
  7. python 输出三角形
  8. IN和EXISTS、not in 和not exists的效率详解
  9. 新版iTunes connect上传iOS应用
  10. dapper通用分页方法