博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF1012A Photo of The Sky(思考,模拟)
阅读量:6871 次
发布时间:2019-06-26

本文共 2692 字,大约阅读时间需要 8 分钟。

A. Photo of The Sky

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.

Strictly speaking, it makes a photo of all points with coordinates (x,y)(x,y), such that x1≤x≤x2x1≤x≤x2 and y1≤y≤y2y1≤y≤y2, where (x1,y1)(x1,y1) and (x2,y2)(x2,y2) are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.

After taking the photo, Pavel wrote down coordinates of nn of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.

Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it's impossible to tell which numbers specify coordinates of which points.

Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.

Input

The first line of the input contains an only integer nn (1≤n≤1000001≤n≤100000), the number of points in Pavel's records.

The second line contains 2⋅n2⋅n integers a1a1, a2a2, ..., a2⋅na2⋅n (1≤ai≤1091≤ai≤109), coordinates, written by Pavel in some order.

Output

Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel's records.

Examples

input

Copy

44 1 3 2 3 2 1 3

output

Copy

1

input

Copy

35 8 5 5 7 5

output

Copy

0

Note

In the first sample stars in Pavel's records can be (1,3)(1,3), (1,3)(1,3), (2,3)(2,3), (2,4)(2,4). In this case, the minimal area of the rectangle, which contains all these points is 11 (rectangle with corners at (1,3)(1,3) and (2,4)(2,4)).

 

给出一堆点的x和y(无序的,无法确定是x还是y)求能覆盖这些点的长方形的最小面积

对x,y进行排序后,得到一个递增序列,我们暂且将他当成这样:

最大值可能在两种情况取到

(前半段与后半段)

或是:

(中间截取一段和剩下来的区段)

然后不断遍历i得出最小值即可

代码:

#include
#include
#include
using namespace std;const int INF=0x3f3f3f3f;const int size=1e5+5;int arr[2*size];int main(){ int n; while(cin>>n) { int i; for(i=0;i<2*n;i++) { scanf("%d",&arr[i]); } sort(arr,arr+2*n); long long a=arr[n-1]-arr[0]; long long b=arr[2*n-1]-arr[n]; long long minn=a*b; a=arr[2*n-1]-arr[0]; for(int i=1;i

 

转载于:https://www.cnblogs.com/fly-white/p/10092776.html

你可能感兴趣的文章
java进阶之路
查看>>
优化Android Studio
查看>>
zabbix二次开发-flask-获取告警
查看>>
我的友情链接
查看>>
java实现MD5加密处理
查看>>
实用JVM参数总结
查看>>
oracle 11g R2 64位 安装详细步骤
查看>>
Jpeg 库的解码OpenCL优化
查看>>
正则表达式
查看>>
『中级篇』docker之虚拟机创建vagrant技巧(番外篇)(81)
查看>>
交换机SPAN功能配置
查看>>
MySQL 架构组成—存储引擎
查看>>
基于数值分析思想对多项式求值的原理和应用进行探究
查看>>
vue-devtools vue开发调试神器
查看>>
PHP扩展模块的安装
查看>>
BGP基础操作
查看>>
SimpleXml项目
查看>>
php下使用PDO创建sqlite3数据库
查看>>
Istio技术与实践6:Istio如何为服务提供安全防护能力
查看>>
ISTP的重要作用
查看>>