CodeChef: June Challenge | Minimum Dual Area DAREA| Python, Java, C++ Solutions
Given NN points in a 2D2D space, find the minimum sum of areas of rectangles required to cover all the points given that we can use at most 22 non-overlapping rectangles whose sides can touch. The rectangles must be axis-aligned, meaning the sides are vertical and horizontal.
For the work from home Internship Programs : Click here to apply now
Input
- The first line contains an integer TT, the number of test cases. Then the test cases follow.
- Each test case contains N+1N+1 lines of input.
- The first line contains a single integer NN, the number of points.
- The next NN lines each contains two integers xixi, yiyi, the coordinates of the ii-th point.
Note: Points need not be distinct.
Output
For each test case, output in a single line the answer to the problem.
Constraints
- 1≤T≤1051≤T≤105
- 1≤N≤1051≤N≤105
- 0≤xi,yi≤1090≤xi,yi≤109
- The sum of NN over all test cases is at most 105105.
Subtasks
Subtask #1 (100 points): original constraints
Sample Input
3
1
100 100
4
1 100
100 100
100 1
1 1
5
1 100
100 100
100 1
1 1
50 50
Sample Output
0
0
4851
Explanation
Case 1: Since there is only one point, the minimum area of a rectangle to cover this point is 00.
Case 2: We can have rectangles as 22 opposite sides of the square. Since the width of the rectangles is 00, the total area is also 00.
Case 3: The optimal solution is with the rectangles having endpoints {(1,1),(100,1),(1,50),(100,50)}{(1,1),(100,1),(1,50),(100,50)} and {(1,100),(1,100),(100,100),(100,100)}{(1,100),(1,100),(100,100),(100,100)}. Therefore the total area is 49⋅99+0⋅99=485149⋅99+0⋅99=4851
Solution
Due to copyright issues we won’t be able to update the solution here immediately. However you can download the code file from our telegram channel. So join our telegram channel for further updates. Keep tracking, the solution will be updated on this website soon.
Read more post Here