Suppose there are 3 non-negative integers $x$, $y$ and $z$ on the real line. We are told that $x + y + z = 300$. Without loss of generality, assume $x$ to be the smallest integer, and $z$ to be the largest.

How do I minimize $(x + z)$?

Attempt: $x + z = 300 - y$, so for a start I should maximize y. This occurs at $y = z - 1$. So, we have $x + 2z = 301$. Now, $z = \dfrac {301}2 - \dfrac x2$. $\dfrac {dz}{dx} = -\dfrac 12$. Increasing $x$ by $1$ decreases $z$ only by $\dfrac12$. So, I should pick the smallest possible $x$, which is $1$. Then, $z = 150$. $\min (x+z) = 151$.


  1. Is my logic correct?
  2. Is there a systematic way to solve questions of this kind? i.e. given non-negative numbers on the real line that sum up to a fixed value, how to minimize the sum of the largest and smallest of them?
  • 2
    $\begingroup$ Do $x$, $y$, $z$ have to be different? Another thing: "nonnegative" means $\geq0$, not $\geq1$. $\endgroup$ – Christian Blatter Jul 28 '12 at 14:46
  • 1
    $\begingroup$ no,minimum of $x+z=150$ not $151$ because let take $x=0$ $y=150$ $z=150$ $\endgroup$ – dato datuashvili Jul 28 '12 at 14:56
  • $\begingroup$ Oh gosh I am sorry, I needed x,y,z to be distinct and non-negative (can be zero). x has to be 1 because if x is 0 then 2z will be 301. $\endgroup$ – Legendre Jul 28 '12 at 15:27

Your logic is fine. Working with integers there are sometimes "end effects". You seem to be requiring that $y \ne z$ and an alternate solution is $(0,149,151)$ but that has the same sum of $x+z$. Without the restriction that $y \ne z$ you could have $(0,150,150)$ for a sum of $150$

Your approach is quite systematic. If you had to have $7$ different non-negative integers sum to $300$ and wanted to minimize the sum of smallest plus largest, you would argue the same way-you want the middle ones to be as large as possible, so you have six numbers that add to $300$ (or a little less), so the average one is $50$, so they are $(47,48,49,50,51,52)$ and you need to add a $3$ to make $300$ and the sum is $3+52=55$. You don't really need the derivative here.

  • $\begingroup$ great answer @Ross Millikan $\endgroup$ – dato datuashvili Jul 28 '12 at 15:30

so let us consider two case


in this case you have $x+2*z=150$. here $x+z$ could be possible if $x=0$ and $z=150$ ; otherwise you get $y$ bigger then $z$,which contradicts condition of being $z$ largest integer,now let us consider second situation


here $x+z=300-y$

because $z>y$,it means that $y<150$ and $z>150$,as $x>=0$ and $z>150$ ,we get $x+z>150$,so only possible is sum of $x+z$ is minimum if and only if $x+z=150$

  • $\begingroup$ Thanks. Sorry I forgot to say x < y < z. $\endgroup$ – Legendre Jul 28 '12 at 15:33
  • $\begingroup$ ok wish you everything best $\endgroup$ – dato datuashvili Jul 28 '12 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.