Problems > Bounding Box

Bounding Box

Difficulty: 1000 3500 ms 128 MB

geometry

Print the area of the smallest axis-aligned rectangle containing all N points (0 if they are collinear on an axis-parallel line).

Input: the first line has N; the next N lines each have x y.

Output: (max x − min x) · (max y − min y).

Constraints:

  • 1 ≤ N ≤ 5×104
  • |coordinates| ≤ 106

Sample Tests

Input 1
3
1 1
4 5
2 3
Output 1
12
Input 2
1
7 7
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.