eolymp
bolt
Try our new interface for solving problems
Problems

Gadgets Factory

Gadgets Factory

Mr. Smith is a very rich gadgets fan. As soon as he realized that he cannot buy all the gadgets he wants just because they are not yet produced, he decided to build his own Gadgets Factory. The Gadgets Factory will be built at a place called "Silicon Road". This road concentrates production of highly technological parts required to produce gadgets. The Silicon Road is straight and the factories are placed very close to it, so the road can be considered as an axis, and factories can be considered as points on it. There are \textbf{n} parts needed to produce gadgets, and \textbf{m} factories that produce these parts. Mr. Smith wants to minimize the sum of squared distances to the nearest factories that produce each of required parts. Help him to find all the points in which that sum is minimal. \includegraphics{https://static.e-olymp.com/content/66/66115626a800ff3fa48345ada2cd226fd9f23f0c.jpg} \InputFile The first line of the input file contains integer numbers \textbf{n} and \textbf{m} (\textbf{1} ≤ \textbf{n} ≤ \textbf{10000}; \textbf{n} ≤ \textbf{m} ≤ \textbf{100000}). Next \textbf{m} lines contain pairs of integer numbers \textbf{x_i} and \textbf{p_i}, \textbf{x_i} is the coordinate of \textbf{i}-th factory, and \textbf{p_i} is the identifier of the part that it produces (|\textbf{x_i}| ≤ \textbf{100000}; \textbf{x_i} ≤ \textbf{x_\{i+1\}}; \textbf{1} ≤ \textbf{p_i} ≤ \textbf{n}). For each required part there is at least one factory that produces it. \OutputFile The first line of the output file should contain an integer number \textbf{k} - the number of points where the Gadgets Factory can be built. Next \textbf{k} lines should contain these points in ascending order. The values should be accurate within an absolute error of \textbf{10^\{-6\}}.
Time limit 3 seconds
Memory limit 256 MiB
Input example #1
3 5
-1 3
0 1
2 3
4 2
5 2
Output example #1
1
2.0
Author Sergey Kopeliovich, Pavel Mavrin