5. There are 2012 distinct points in the plane each of which is to be coloured using one of $n$ colours so that the number of points of each colour are distinct. A set of $n$ points is said to be multi-coloured if their colours are distinct. Determine $n$ that maximizes the number of multi-coloured sets.
5. Let $m_{1}1$. For if $m_{1}=1$, then $m_{1} m_{2} \ldots m_{n}n$, we have $n=8$ and $m_{1}=248$. The colour distribution with $m_{1}$ replaced by two numbers 2,246 (using $n+1$ colours) yields a larger $M$.
(v) $m_{1}=2$. If $m_{n}-m_{n-1}=2$, then from (iv), we have $m_{1}+\cdots+m_{n}=$ $n m_{1}+\frac{n(n-1)}{2}+1=2012$. Thus $n\left(2 m_{1}-1+n\right)=2 \cdot 2011$. Since 2011 is prime, we get $n=2$ and $m_{1}=1005$ which will lead to a contradiction as in (iv). Thus $m_{n}-m_{n-1}=1$. $m_{i+1}-m_{i}=2$ for some $1 \leq i \leq n-2$. Suppose $m_{1} \geq 3$. Let $m^{\prime}=m_{i+2}-2$. Then $m_{i}<m^{\prime}<m_{i+1}$ with replacing $m_{i+2}$ by $2, m^{\prime}$ yields a larger $M$. Thus $m_{1}=2$.

From the above analysis, with $n$ colours, we see that the colour distribution 2, 3, $\ldots, i-1, i+1, i+2, \ldots, n+1, n+2$, with $3 \leq i \leq n$, yields the maximum $M$. Now we have $\sum m_{i}=\frac{1}{2}(n+1)(n+4)-i=2012$. Thus $n^{2}+5 n-4020=2 i, 3 \leq i \leq n$, i.e., $n^{2}+5 n \geq 4026$ and $n^{2}+3 n \leq 4020$. Thus $n=61$ and $i=3$. Thus the maximum is achieved when $n=61$ with the colour distribution $2,4,5,6, \ldots, 63$.