Minimize the jealousy function

74 Views Asked by At

Given:
$m$ chocolates and $n$ students with jealousy value $\{j_1, j_2,...j_n\}$ where $0<j_i<100$.

To Do:

  • Distribute these chocolates among students $\{c_1, c_2,...c_n\}$ such that $\sum_{i=1}^{n}c_i=m$   and,
  • Minimise total jealousy $J(c_1,c_2,..c_n)= \sum_{i=1}^n j_i*x_{c_i}$
    Note:
    • $x_{c_i}$ is the number of students who received $>c_i$ chocolates.
    • $j_i*x_{c_i}$ represents jealousy of $i^{th}$ student.
    • $c_i \ge0$. It can be $0$ too.

Example:
There are $9$ chocolates and $3$ students with jealousy values $\{10, 20, 30\}.$
$\therefore$ minimum value of total jealousy will be $0$ as we can distribute $3$ chocolates to each student $\implies x_1=x_2=x_3=0$.
If we distributed chocolates as $\{1,4,4\}$
$\implies J = 10*2+20*0+30*0=20$.