ZCO Rectangle

Hello, I tried to solve - CodeChef: Practical coding for everyone

My code is #include <iostream>#include <vector>#include <algorithm>using namespace st - Pastebin.com

Unfortunately my algorithm isn’t efficient enough, it times out in the second subtasks

First the points are sorted by the values of their x axis and then area is calculated between two adjacent points with y = 500. This is easy because the rectangles are guaranteed to be on the x axis.

After this points are sorted by values of their y axis. Then I keep track of all points for x axis. Find adjacent x axis points using binary search and then find the area. The code should be able to explain better what I’m trying to say.

However it seems to be too slow. Can anyone point out a way to make it faster?

Fixed it. Working code - #include <iostream>#include <vector>#include <algorithm>#include <stdlib.h - Pastebin.com

With this I’ve finished all problems in the practice contest. If anyone needs the code for any of the questions feel free to contact me.