I have two quadratic functions $$W(x_1,x_2,\ldots,x_n)=\sum_{i}^{n} a_{ii} x_i^2+ \sum_{i\neq j}^{n} a_{ij}x_ix_j+\sum_{i}^{n} b_{i} x_i, $$ and $$V(x_1,x_2,\ldots,x_n)=\sum_{i}^{n} c_{ii} x_i^2+ \sum_{i\neq j}^{n} c_{ij}x_ix_j+\sum_{i}^{n} d_{i} x_i,$$with $x_i\in[0,1)$. Both functions are subject to constraint $\sum_{i}x_i \leq M$ where $M<n$. All parameters $a_{ii}, a_{ij}$, $b_{ii}$, $b_{ij}$ and $d_i$, $b_{i}$ to be non-negative. Note I split the second order terms, they can be written into one term like $\sum_{i}^{n}\sum_{j}^{n} a_{ij}x_ix_j$.
My question is, when will the two functions have the same maximizer? A sufficient condition is when the parameters are all same: $a_{ij}=c_{ij}$, $b_i=d_i$, for all $i,j$. Or parameters of $V$ is proportional to parameters of $W$. See Why coefficients have to be proportional for two quadratic functions to have the same roots. But is this necessary? Other than special cases where they are multiples of each other, can I have a simple necessary and sufficient condition? Thanks in advance.