Thursday, September 4, 2014

COJ 1179. Optimal Parking

  The task might not be very clear on the statement part or maybe it is left up to the reader to understand. Anyway, the task wants the best coordinate to park where the distance which we walk would be minimal, and the distance means, getting out of the car, entering every store and coming back to the car. No matter where we park our car the distance walked will be minimal if we get to the beginning (or to the end) of the line and start visiting stores one after another until we have reached the other end of the line and then we also need to add the distance which takes from the other end of the line to our car. The constraints are only from 0 to 99 so we can just try out every single coordinate and calculate with brute force method.


      FULL SOURCE CODE

No comments:

Post a Comment