How it works as you mention sorted(max(del(Xi))) * sorted(max(del(Yi))) ? Because coordinate for each tower is specify for each tower? If I sorted coordinate will change for each tower from it’s given coordinate?
Defense of a Kingdom - Spoj
Hi Asif, please try to solve this problem by drawing a grid on paper and then draw line in the grid for each x and y. Now shuffle the y’s internally and again draw the lines in another grid. You will notice that design of grid in both graphs remain same despite of jumbled order of oordinates.
For example consider the input as:
3
1, 2
4, 5
3, 6
&
3
1, 5
4, 6
3, 2
when you make a grid and then cut lines for both these testcases you will realize that x&y does not matter as a pair but matters individually in a seperate list of x-coordinates and y-coordinates.
We are following the GREEDY approach here and whose answer is always correct.