The spotlight is back on the Jiahai Potato Farm (JPF) again! The potatoes are all happy with their new WiFi connection and all of a sudden, one of them discovers terrible news! A hurricane is heading in their direction, and there's very little time to take cover! One of them immediately informs Jiahai, and Jiahai is now forced to take measures.
Being an incredibly intelligent farmer, Jiahai has decided to buy a huge blanket that can be used to cover all the potatoes and protect them from the hurricane winds. Given the X and Y coordinates of all the potatoes on the Jiahai Potato Farm, determine the minimum size of the blanket required to cover all the potatoes. The edges of the blanket must be parallel to the X and Y axes and follow along the integer gridlines. NOTE: A potato at a corner of the blanket is considered to be covered.
One possible configuration of JPF is given as follows:
In this case, the blanket will be from (5, 5) to (26, 17), covering an area of 252 units.
There will be N potatoes in JPF. You will be given N and two arrays, X and Y. (X, Y) will be the coordinates of the first potato, (X, Y) will be the coordinates of the second potato, etc.
Your program will be required to implement the following functions:
- long long int blanketSize(int N, int X, int Y), which should return the minimum blanket size needed.
Subtask 1 (34%): 1 <= N
<= 1 000
Subtask 2 (66%): 1 <= N
<= 1 000 000
Sample Input 1
Sample Output 1