Optimal rounding a sequence of reals to integers I'm given positive real numbers $c_1,\dots,c_m \in \mathbb{R}$ and an integer $d \in \mathbb{N}$.  My goal is to find non-negative integers $x_1,\dots,x_m \in \mathbb{N}$ that minimize $\sum_i (x_i - c_i)^2$, subject to the requirement $\sum_i x_i = d$.
I'm inclined to suspect that there exists $t \in \mathbb{R}$ such that the optimal solution is $x_i = \lfloor t c_i \rceil$ for all $i$ (i.e., take $x_i$ to be $tc_i$ rounded to the nearest integer).  Is this the case?
My first instinct was to apply Lagrange multipliers, but I guess that doesn't work given the requirement that $x_1,\dots,x_m$ be integers.

Motivation: I'm trying to help with someone's quantization problem, but the problem seems fun in its own right.

This is an MIQP (Mixed Integer Quadratic Programming) problem. This version is the easy one: convex. That means there are quite a few good solvers available to handle this. Still, finding proven global optimal solutions is often difficult. On the other hand, solvers find typically good solutions very quickly. For $n=1000$ a good solver should take no more than a few seconds to find a global optimal solution. 
