School recruit Zhenti exercises 028 city construction (360)

Urban construction

There is a need to build cities, to give you the coordinates of N houses X, Y, and asked to so many houses are all packed into the city, then, is how much the minimum required area of ​​the city (note city square parallel to the axis)

Input Description :
The first row N, the number of houses (2≤N≤1000)

Output Description :
required minimum area of the city

 1 import sys
 2 N = int(input())
 3 minx,maxx,miny,maxy = sys.maxsize,-sys.maxsize,sys.maxsize,-sys.maxsize
 4 for _ in range(N):
 5     ary = list(map(int,input().split()))
 6     x,y = ary[0],ary[1]
 7     minx = min(minx,x)
 8     maxx = max(maxx,x)
 9     miny = min(miny,y)
10     maxy = max(maxy,y)
11 area = max(abs(maxx-minx),abs(maxy-miny)) ** 2
12 print(area)

 

Guess you like

Origin www.cnblogs.com/asenyang/p/11275814.html