Help needed to solve Rectangle (ZCO15004 DSA Week2)

I am getting WA on Rectangle problem from DSA Series Week 2: ZCO15004

Here is my solution: CodeChef: Practical coding for everyone

Please clarify what is the issue here with my code/approach.

My approach:

  • Find the maximum difference between all x-coordinates. Multiply this by 500 (maximum height). Let this be ans1

  • Find the minimum y-coordinate and multiply it by 10^5 (maximum width). Lets call this ans2.

  • Find the result of 10^5 - max(x-coordinates) * 500. (rectangle starting at max(x-coordinate) and ending at (100000, 500)) Lets call this ans3.

  • Find the result of min(x-coordinates) * 500 (Rectangle starting at (0, 0) and ending at (min(x-coordinates), 500)). Lets call this ans4.

  • Print max(ans1, ans2, ans3, ans4)

There are a lot of other possible cases. Just imagine a lot of (x, 499) with (1,1). None of your cases can handle that.

Try using a brute force with some optimisations.

1 Like