minimum total travel distance (from N people) | Algorithms | C++ | manhattan grid
- v2 C++ file reads input from file instead of command line arguments (uses array of non constant size work with g++ extension compiler)
- original version uses dyanamic memory allocation (compatible with all c++ compilers)
*Data Input: reads from standard input a positive integer N (indicates how many students live in squaretown) and it continues by reading N pairs of positive integers x y (pair indicates the position of the student's house in the grid).
*Data Output: program prints in standard output the total traveled distance (of all the the students) in order to reach the meeting point.
Restrictions:
* 3 <= N <= 510^5 , 2<= M <= 10^7 (M: M horizontal and vertical roads in the grid)
* Memory limit: 64 MB
* Time limit: 1sec