# Minimize sum of smallest and largest among integers on the real line.

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$.

Questions

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?
-
Do $x$, $y$, $z$ have to be different? Another thing: "nonnegative" means $\geq0$, not $\geq1$. – Christian Blatter Jul 28 '12 at 14:46
no,minimum of $x+z=150$ not $151$ because let take $x=0$ $y=150$ $z=150$ – dato datuashvili Jul 28 '12 at 14:56
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. – 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.

-
great answer @Ross Millikan – dato datuashvili Jul 28 '12 at 15:30
Thanks for your help! – Legendre Jul 28 '12 at 15:45

so let us consider two case

1.$z=y$

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

2.$z>y$

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$

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