E. Pencils and Boxes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output
Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a1, a2, ..., an a 1 , a 2 , . . . , a n of n integer numbers — saturation of the color of each pencil. Now Mishka wants to put all the mess in the pack in order. He has an infinite number of empty boxes to do this. He would like to fill some boxes in such a way that:
- Each pencil belongs to exactly one box;
- Each non-empty box has at least k k pencils in it;
- If pencils and j j belong to the same box, then , where |x| | x | means absolute value of x x . Note that the opposite is optional, there can be pencils and j j such that