Let $a_0,a_1,a_2,\dots $ be a sequence of real numbers such that $a_0=0, a_1=1,$ and for every $n\geq 2$ there exists $1 \leq k \leq n$ satisfying \[ a_n=\frac{a_{n-1}+\dots + a_{n-k}}{k}. \]Find the maximum possible value of $a_{2018}-a_{2017}$.
Problem
Source: IMO Shortlist 2018 A4
Tags: algebra, Sequences, IMO Shortlist, maximum value, IMO shortlist 2018
17.07.2019 16:06
The best bounds (in both directions!) are $-\frac{1}{2018} \le a_{2018} - a_{2017} \le \frac{2016}{2017^2}$. We will define for each $n$ the values \begin{align*} m_n &= \min_{1 \le k \le n} \frac{a_{n-1} + \dots + a_{n-k}}{k} \\ M_n &= \max_{1 \le k \le n} \frac{a_{n-1} + \dots + a_{n-k}}{k}. \end{align*}Thus, for each $n$, we have $a_n \in [m_n, M_n]$. \medskip Part I. Smoothing. Note that we are focused on the extremal values of $a_{2018} - a_{2017}$. We use the following cool idea. Claim: [Smoothing] We may as well assume $a_n \in \{m_n, M_n\}$ in a maximal sequence. Proof. Note that the sequence is uniquely determined by the choice of index $1 \le k(n) \le n$ for $n = 1, 2, \dots, 2018$. We prove that we may as well choose this index such that $a_{k(n)} \in \{m_n, M_n\}$. Indeed, start from any choice of $k(n)$ and fix all but one of the indices $k(n_0)$. Then the objective function $a_{2018} - a_{2017}$ is a linear function in $a_{n_0}$; so it takes its extreme values at the endpoints, as needed. Doing this procedure for $n_0 = 2, 3, \dots, 2018$ does it. $\blacksquare$ We assume henceforth we are in the situation of the previous claim, with $a_n \in \{m_n, M_n\}$ for each $n$. (We will not use the ``maximality'' fact.) Claim: For any $n$, we have \[ m_n = \frac{a_0 + \dots + a_{n-1}}{n} \qquad\text{and}\qquad M_n = \frac{a_1 + \dots + a_{n-1}}{n-1}. \]In other the minimum is achieved by averaging everything, and the maximum is achieved by averaging all but $a_0$. Proof. Induction by $n$, after smoothing. $\blacksquare$ \medskip Part II. Explicit recursion. Define $\Delta_n = M_n - m_n \ge 0$. In making our choices we see that $(m_n, M_N)$ are now defined recursively in the following way. If we choose $a_n = m_n$ then $m_{n+1} = m_n$ and $M_{n+1} = \frac{m_n + (n-1)M_n}{n}$; hence $\Delta_n = \frac{n-1}{n} \Delta_n$. If we choose $a_n = M_n$ then $m_{n+1} = \frac{nm_n + M_n}{n+1}$ and $M_{n+1} = M_n$; hence $\Delta_n = \frac{n}{n+1} \Delta_n$. In particular, we always have \[ \Delta_{n+1} \le \frac{n}{n+1} \Delta_{n-1} \]and since $\Delta_1 = \frac{1}{2}$, we can telescope to get \[ \Delta_{2017} \le \frac{2016}{2017} \cdot \frac{2015}{2016} \cdot \dots \cdot \frac{1}{2} = \frac{1}{2017}. \] \medskip Part III. Answer extraction. We now extract the answer to the problem. Assume that $a_1$, \dots, $a_{2016}$ are chosen. Then to have $a_{2017} \ne a_{2018}$, we pick either $(a_{2017}, a_{2018}) = (m_{2017}, M_{2018})$ or $(a_{2017}, a_{2018}) = (M_{2017}, m_{2018})$ In the first case, $a_{2018} = M_{2018} = \frac{m_{2017} + 2016 M_{2017}}{2017}$ and so \begin{align*} 0 &\le a_{2018} - a_{2017} = \frac{m_{2017} + 2016 M_{2017}}{2017} - m_{2017} \\ &= \frac{2016}{2017} \Delta_{2017} \le \frac{2016}{2017^2}. \end{align*}To achieve this, take the sequence \[ a_1 = a_2 = \dots = a_{2016} = 1, \quad a_{2017} = \frac{2016}{2017}, \quad a_{2018} = \frac{2016 \cdot 2018}{2017^2}. \] In the second case, $a_{2018} = m_{2018} = \frac{m_{2018} + 2017M_{2017}}{2018}$ and so \begin{align*} 0 &\ge a_{2018} - a_{2017} = \frac{2017m_{2017}+M_{2017}}{2018} - M_{2017} \\ &= -\frac{2017}{2018} \Delta_{2017} \ge -\frac{1}{2018} \end{align*}To achieve this, take the sequence \[ a_1 = a_2 = \dots = a_{2017} = 1, \quad a_{2018} = \frac{2017}{2018}. \] This concludes the proof.
01.08.2019 22:23
Corrected solution is below. Thanks to Luke Robitaille for help catching and correcting technical mistakes in this long and technical solution! We claim that \[a_n-a_{n-1}\le\boxed{\frac{n-2}{(n-1)^2}}.\]Equality is achieved at the sequence $a_1=\cdots=a_{n-2}=1$, $a_{n-1}=\frac{n-2}{n-1}$, and $a_n=\frac{n(n-2)}{(n-1)^2}$. We now prove the bound. To do so, we have the following crucial claim. Before doing so, for $1\le k\le n$, define \[f_n(k):=\frac{a_{n-1}+\cdots+a_{n-k}}{k}.\] Claim: For $1\le k,\ell\le n$, we have that \[|f_n(k)-f_n(\ell)|\le\frac{k+1}{k}\frac{n-1}{n^2}.\] Proof: We proceed by induction on $n$. The case $n=1$ is trivial since there is only one possibility for $k,\ell$, namely $k=\ell=1$. Now, suppose the claim is true for $n-1$. WLOG, suppose $k>\ell$ (if $k=\ell$ then the left side is $0$ so the inequality trivially holds). Then, it suffices to show that \[|f_n(k)-f_n(\ell)|\le\frac{k+1}{k}\frac{n-1}{n^2}\]since $1+1/k<1+1/\ell$. Note that \begin{align*} f_n(k) &= \frac{1}{k}a_{n-1} + \frac{k-1}{k}f_{n-1}(k-1) \\ f_n(\ell) &= \frac{1}{\ell}a_{n-1} + \frac{\ell-1}{\ell}f_{n-1}(\ell-1). \end{align*}Let $\gamma=f_{n-1}(k-1)-a_{n-1}$ and $\delta=f_{n-1}(\ell-1)-a_{n-1}$. The claim for $n-1$ implies that \[|\gamma|,|\gamma-\delta|\le\frac{k}{k-1}\frac{n-1}{(n-2)^2}\]and \[|\delta|\le\frac{\ell}{\ell-1}\frac{n-1}{(n-2)^2}\]since $a_{n-1}=f_{n-1}(r)$ for some $r$. We simply want to show that \[D:=\left|\frac{k-1}{k}\gamma-\frac{\ell-1}{\ell}\delta\right|\le\frac{k+1}{k}\frac{n-1}{n^2}.\]Note that if $k=1$ or $\ell=1$, then this is immediately true by the bounds for $|\gamma|$ and $|\delta|$. So we may assume $k,\ell\ge 2$. In fact, we'll show that for any integers $2\le \ell<k\le n$ and real numbers $\gamma,\delta$ such that $|\gamma|,|\gamma-\delta|\le\frac{k}{k-1}\frac{n-2}{(n-1)^2}$ and $|\delta|\le\frac{\ell}{\ell-1}\frac{n-1}{(n-2)^2}$, we must have that $D\le\frac{k+1}{k}\frac{n-1}{n^2}$. WLOG, suppose $\gamma\ge 0$. We now have three cases. Case 1: $0\le\delta\le\gamma$. We see that $\frac{k-1}{k}\gamma>\frac{\ell-1}{\ell}\delta$ since $k>\ell$ and $\gamma\ge\delta$, so we must have \[D\le\frac{k-1}{k}\gamma\le\frac{k-1}{k}\frac{k}{k-1}\frac{n-2}{(n-1)^2}.\]Thus, $D\le\frac{n-2}{(n-1)^2}$. Case 2: $\delta\le 0\le\gamma$. Here, we see that $\gamma$ and $\delta$ both move closer to each other. In particular, \[D=|\gamma|+|\delta|-\frac{1}{k}|\gamma|-\frac{1}{\ell}|\delta|\le\frac{k-1}{k}(|\gamma|+|\delta|),\]so \[D\le\frac{k-1}{k}|\gamma-\delta|\le\frac{n-2}{(n-1)^2}.\]Thus, $D\le\frac{n-2}{(n-1)^2}$ again. Case 3: $0\le\gamma\le\delta$. We see that \[D=\left|\delta-\gamma+\frac{1}{k}\gamma-\frac{1}{\ell}\delta\right|.\]Firstly, if $D=-\left(\delta-\gamma+\frac{1}{k}\gamma-\frac{1}{\ell}\delta\right)$, then \[D\le\frac{1}{\ell}\delta\le\frac{1}{\ell-1}\frac{n-2}{(n-1)^2}\le\frac{n-2}{(n-1)^2}.\]Thus, \[D\le\frac{n-2}{(n-1)^2}.\] Now, if \[D=\delta-\gamma+\frac{1}{k}\gamma-\frac{1}{\ell}\delta,\]then $D\le\delta-\gamma$. So if $\delta-\gamma\le\frac{k+1}{k}\frac{n-1}{n^2}$, we'd already be done. Thus, WLOG, we may assume \[\delta-\gamma>\frac{k+1}{k}\frac{n-1}{n^2}.\]We now have \begin{align*} D &< \delta-\gamma+\frac{1}{k}\gamma-\frac{1}{\ell}\left(\gamma+\frac{k+1}{k}\frac{n-1}{n^2}\right) \\ &= \delta-\gamma-\frac{1}{\ell k}\left((k-\ell)\gamma+(k+1)\frac{n-1}{n^2}\right) \\ &<\frac{k}{k-1}\frac{n-2}{(n-1)^2}-\frac{k+1}{k(k-1)}\frac{n-1}{n^2}. \end{align*}Note that \begin{align*} &\frac{k+1}{k(k-1)}\frac{n-1}{n^2}\ge\frac{1}{k-1}\frac{n-2}{(n-1)^2} \\ &\iff (1+1/k)(n-1)^3\ge n^2(n-2) \\ &\Longleftarrow \frac{n+1}{n}(n-1)^3\ge n^2(n-2) \\ &\iff (n+1)(n-1)^3\ge n^3(n-2) \\ &\iff (n^2-1)(n-1)^2\ge n^2((n-1)^2-1) \\ &\iff -(n-1)^2\ge -n^2 \end{align*}which is certainly true. Thus, \[D<\frac{n-2}{(n-1)^2},\]once again. Thus, in all cases, $D\le\frac{n-2}{(n-1)^2}$. Thus, we have \[\frac{k+1}{k}\frac{n-1}{n^2}\ge\frac{n+1}{n}\frac{n-1}{n^2},\]so $D\le\frac{k+1}{k}\frac{n-1}{n^2}$ would be implied by \[\frac{n-2}{(n-1)^2}\le\frac{(n+1)(n-1)}{n^3},\]or $(n+1)(n-1)^3\ge n^3(n-2)$, which we showed above is true. Thus, we have $D\le\frac{k+1}{k}\frac{n-1}{n^2}$, so the claim is proven. $\blacksquare$ The claim now implies \[\frac{a_{n-2}+\cdots+a_{n-k}}{k-1}-a_{n-1}\le\frac{k}{k-1}\frac{n-2}{(n-1)^2}.\]We see that \[a_n-a_{n-1}=\frac{a_{n-1}+\cdots+a_{n-k}}{k}-a_{n-1}=\frac{k-1}{k}\left(\frac{a_{n-2}+\cdots+a_{n-k}}{k-1}-a_{n-1}\right)\le\frac{n-2}{(n-1)^2},\]as desired. Thus, the maximum we want is $\boxed{\frac{2016}{2017^2}}$. Remark Luke Robitaille points out that a much faster way to prove the claim is to note that \[D=\left|\left(\frac{k-1}{k}-\frac{\ell-1}{\ell}\right)\gamma+\frac{\ell-1}{\ell}(\gamma-\delta)\right|\ge\frac{n-2}{(n-1)^2}\]by the triangle inequality.
01.08.2019 22:33
The answer is $\tfrac{2016}{2017^2}$. To see that $\tfrac{2016}{2017^2}$ may be achieved, consider the sequence \[a_0 = 0, \quad a_1 = \dots = a_{2016} = 1, \quad a_{2017} = 1 - \frac{1}{2017}, \quad a_{2018} = 1 - \frac{1}{2017^2}.\]Now we prove this is optimal. Define the auxillary sequences \[u_n = \min_k \frac{a_{n-1} + \dots + a_{n-k}}{k} \quad \text{and} \quad v_n = \max_k \frac{a_{n-1} + \dots + a_{n-k}}{k}.\]By linearity, in the optimal sequence, $a_n \in \{u_n, v_n\}$ for each $n$. In addition it is not hard to see that $a_{2017} = u_{2017}$ and $a_{2018} = v_{2018}$. Now we prove two similar claims which form the core of the proof. Claim A. If $a_n = v_n$, then $v_{n+1} - u_{n+1} \le \tfrac{n}{n+1} \cdot (v_n - u_n)$. Proof. Clearly $v_{n+1} = v_n$. Note \begin{align*} u_{n+1} & = \min_k \frac{v_n + a_{n-1} + \dots + a_{n-k}}{k+1}\\ & = \min_k \left(\frac{1}{k+1} \cdot v_n + \frac{k}{k+1} \cdot \frac{a_{n-1} + \dots + a_{n-k}}{k}\right)\\ & \ge \min_k \left(\frac{1}{n+1} \cdot v_n + \frac{n}{n+1} \cdot \frac{a_{n-1} + \dots + a_{n-k}}{k}\right)\\ & = \frac{1}{n+1} v_n + \frac{n}{n+1} u_n\\ \implies v_{n+1} - u_{n+1} & \le \frac{n}{n+1} \cdot (v_n - u_n) \end{align*}as requested. Claim B. If $a_n = u_n$, then $v_{n+1} - u_{n+1} \le \tfrac{n-1}{n} \cdot (v_n - u_n)$. Proof. Clearly $u_{n+1} = u_n$. Note \begin{align*} v_{n+1} & = \max_k \frac{u_n + a_{n-1} + \dots + a_{n-k}}{k+1}\\ & = \max_k \left(\frac{1}{k+1} \cdot u_n + \frac{k}{k+1} \cdot \frac{a_{n-1} + \dots + a_{n-k}}{k}\right)\\ & \le \max_k \left(\frac{1}{n} \cdot u_n + \frac{n-1}{n} \cdot \frac{a_{n-1} + \dots + a_{n-k}}{k}\right)\\ & = \frac{1}{n} u_n + \frac{n-1}{n} v_n\\ \implies v_{n+1} - u_{n+1} & \le \frac{n-1}{n} \cdot (v_n - u_n) \end{align*}as requested. (We can do slightly better here because $k \ne n$ in the optimal $v_n$ expression.) We are ready to conclude the solution. Note that $v_{n+1} - u_{n+1} \le \tfrac{n}{n+1} \cdot (v_n - u_n)$ for $n \in \{2, 3, \dots, 2016\}$ and $v_{n+1} - u_{n+1} \le \tfrac{n-1}{n} \cdot (v_n - u_n)$ for $n = 2017$. Thus \begin{align*} a_{2018} - a_{2017} = v_{2018} - u_{2017} & = v_{2018} - u_{2018}\\ & \le \frac{2}{3} \cdot \frac{3}{4} \cdots \frac{2016}{2017} \cdot \frac{2016}{2017} \cdot (v_2 - u_2)\\ & = \frac{2016}{2017^2} \end{align*}and we are done.
15.09.2019 17:22
Claim: In order to minimize $a_i$, we should take $a_i=\frac{a_{i-1}+\ldots+a_{0}}{i}$ Proof: Suppose the minimum of $a_i$ is $m$, and $k$ is the smallest number such that $\frac{a_{i-1}+\ldots+a_k}{i-k}=m$. Then, we must have $a_k\le m$, or else we could take $\frac{a_{i-1}+\ldots+a_{k+1}}{i-k-1}$ to get a smaller average. However, if $k>2$, then we can write $a_k=\frac{a_{k-1}+\ldots+a_{j}}{k-j}\le m$, so if we extend our average to $a_j$, it will still be at most $m$, contradicting minimality of $k$. Hence, $k=0,1$. Obviously, if we want minimum, then we should set $k=0$. In fact, this argument can be repeated to get that $\frac{a_{i-1}+\ldots+a_1}{i-1}$ will maximize $a_i$. We wish to maximize $a_{2018}-a_{2017}$. After $a_0,\ldots,a_{2017}$ have been determined, we obviously want to maximize $a_{2018}$, so $a_{2018}=\frac{a_1+\ldots+a_{2017}}{2017}$. So, the coefficient of $a_{2017}$ in $a_{2018}-a_{2017}$ is $-\frac{2016}{2017}<0$. So, to maximize the difference, we should minimize $a_{2017}$. From now on, we will inductively show that the remaining variables (i.e. $a_2,a_3,\ldots,a_{2016}$) should all be maximized. Suppose we already know $a_{2016},\ldots,a_{i+1}$ should be maximized. Then, if we let $a_i=k$, we know that the coefficient of $k$ in the values of $a_{i+1}$ through $a_{2016}$ are already fixed, by our claim. If we let the sum of all such coefficients be $S$, then we know that the coefficient of $k$ in $a_{2017}$ is $\frac{S+1}{2017}$, since we are minimizing it. This makes the coefficient of $k$ in $a_{2018}$ $\frac{\frac{S+1}{2017}+S+1}{2017}>\frac{S+1}{2017}$. Therefore, the coefficient of $k$ in $a_{2018}-a_{2017}$ is positive, and we should maximize it in order to maximize the difference. Now, we can just compute all the terms. Our sequence should look like $0,1,1\ldots, 1, \frac{2016}{2017},\frac{\frac{2016}{2017}+2016}{2017}$, which makes the answer $\frac{2016}{2017^2}$
04.01.2020 15:49
Functional wrote: Let $a_0,a_1,a_2,\dots $ be a sequence of real numbers such that $a_0=0, a_1=1,$ and for every $n\geq 2$ there exists $1\geq k \geq n$ satisfying $$a_n=\frac{a_{n-1}+\dots + a_{n-k}}{k}.$$Find the maximum possible value of $a_{2018}-a_{2017}$. Anw shouldn't this be $1 \le k \le n$?
09.02.2020 19:17
Let's define sequence $p$ as prefix sum of sequence $a$. ($p_i = a_0 + \dots + a_{i}$ and $p_{-1} = 0$ to complement) $a_n=\frac{a_{n-1}+\dots + a_{n-k}}{k}$ would mean $p_n - p_{n - 1} = \frac{p_{n - 1} - p_{n - k - 1} }{k}$. With small modification: $\frac{p_n - p_{n-1}}{n - (n - 1)} = \frac{p_{n - 1} - p_{n - k - 1}}{(n - 1) - (n - k - 1)}$ which looks like a gradient. So if we plot points $P_i = (i, p_i)$ it would mean points $P_n, P_{n - 1}, P_{n - k - 1}$ are collinear. We can say $P_n$ is the intersection of line $x = n$ and $P_{n - 1}P_{n - k -1}$. Claim: Points $P_1, \dots, P_{n-1}$ are inside triangle $P_{-1}P_0P_n$ Proof: Induction by $n$. It is true for $n = 1$. Suppose it's true for $n - 1$. Because points $P_1, \dots, P_{n-2}$ are inside triangle $P_{-1}P_0P_{n-1}$ already, we should only prove point $P_{n-1}$ is inside $P_{-1}P_0P_n$. Plus we can generalize and say $P_n$ is intersection of line $x = n$ and a line connecting $P_{n-1}$ and a point in $P_{-1}P_0P_{n-1}$.(This generalization will be used later again.) [asy][asy] /* Geogebra to Asymptote conversion, documentation at artofproblemsolving.com/Wiki go to User:Azjps/geogebra */ import graph; size(10cm); real labelscalefactor = 0.5; /* changes label-to-point distance */ pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */ pen dotstyle = black; /* point style */ real xmin = -1.2013789018615188, xmax = 2.620311420198985, ymin = -0.3232188986945089, ymax = 2.5495926217371513; /* image dimensions */ pen wrwrwr = rgb(0.3803921568627451,0.3803921568627451,0.3803921568627451); /* draw figures */ draw((xmin, 0*xmin + 0)--(xmax, 0*xmax + 0), linewidth(0.8) + wrwrwr); /* line */ draw((-1,0)--(xmax, 0.4877470430168052*xmax + 0.4877470430168052), linewidth(0.4) + wrwrwr); /* ray */ draw((0,0)--(xmax, 1.1564787255763065*xmax + 0), linewidth(0.4) + wrwrwr); /* ray */ draw((2,ymin)--(2,ymax), linewidth(0.8) + wrwrwr); /* line */ draw((xmin, 0.7370951526721139*xmin + 0.3058821690501292)--(xmax, 0.7370951526721139*xmax + 0.3058821690501292), linewidth(0.8) + linetype("4 4") + wrwrwr); /* line */ /* dots and labels */ dot((-1,0),linewidth(3pt) + dotstyle); label("$P_{-1}$", (-0.980287934287447,-0.1096311568559604), NE * labelscalefactor); dot((0,0),linewidth(3pt) + dotstyle); label("$P_{0}$", (0.021738793758978858,-0.10435733197150553), NE * labelscalefactor); dot((0.7293613503550539,0.8434908849432268),linewidth(3pt) + dotstyle); label("$P_{n-1}$", (0.7653481024671159,0.744728474425729), NE * labelscalefactor); dot((2,1.4632411290504157),linewidth(3pt) + dotstyle); dot((2,2.312957451152613),linewidth(3pt) + dotstyle); dot((2,1.780072474394357),linewidth(3pt) + dotstyle); label("$P_{n}$", (2.052161374274105,1.6729216540897867), NE * labelscalefactor); dot((0.3379110617044422,0.5549547746667611),linewidth(3pt) + dotstyle); label("$P_{n-k-1}$", (0.34871593659518096,0.454668105780711), NE * labelscalefactor); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); /* end of picture */[/asy][/asy] You can see $\angle P_{-1}P_{n-1}P_n, \angle P_nP_{n-1}P_0, \angle P_0P_{n-1}P_{-1}$ are all $\le 180^{\circ}$, thus $P_{n-1}$ is inside $P_{-1}P_0P_n$. Let's find $a_{2018} - a_{2017}$. Let's say line $P_{2016}P_{2017}$ intersects $x = 0$ at $B$ and intersects $x = 2018$ at $C$. Let's say line $P_{-1}P_{2016}$ intersects $x = 0$ at $B$ and intersects $x = 2018$ at $D$. Let's say line $P_{2017}P_{2018}$ intersects $x = 0$ at $A$. $a_{2018}$ is the gradient of $P_{2017}P_{2018}$. $a_{2017}$ is the gradient of $P_{2016}P_{2017}$. [asy][asy] /* Geogebra to Asymptote conversion, documentation at artofproblemsolving.com/Wiki go to User:Azjps/geogebra */ import graph; size(15cm); real labelscalefactor = 0.5; /* changes label-to-point distance */ pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */ pen dotstyle = black; /* point style */ real xmin = -1.6887789474408115, xmax = 2.435665652692455, ymin = -0.3024668141984523, ymax = 1.700012994342644; /* image dimensions */ pen wrwrwr = rgb(0.3803921568627451,0.3803921568627451,0.3803921568627451); pen sexdts = rgb(0.1803921568627451,0.49019607843137253,0.19607843137254902); /* draw figures */ draw((xmin, 0*xmin + 0)--(xmax, 0*xmax + 0), linewidth(0.8) + wrwrwr); /* line */ draw((-1,0)--(xmax, 0.44669114324194337*xmax + 0.44669114324194337), linewidth(0.4) + wrwrwr); /* ray */ draw((0,0)--(xmax, 0.9095136758535557*xmax + 0), linewidth(0.4) + wrwrwr); /* ray */ draw((1.5,ymin)--(1.5,ymax), linewidth(0.8) + sexdts); /* line */ draw((2,ymin)--(2,ymax), linewidth(0.8) + wrwrwr); /* line */ draw((xmin, 0.4966707774284924*xmin + 0.398453517887737)--(xmax, 0.4966707774284924*xmax + 0.398453517887737), linewidth(0.8) + linetype("4 4") + wrwrwr); /* line */ draw((xmin, 0.7321477739412332*xmin + 0.04523802311862646)--(xmax, 0.7321477739412332*xmax + 0.04523802311862646), linewidth(0.8) + linetype("4 4") + wrwrwr); /* line */ draw((0,ymin)--(0,ymax), linewidth(0.8) + wrwrwr); /* line */ /* dots and labels */ dot((-1,0),linewidth(3pt) + dotstyle); label("$P_{-1}$", (-1.1134808808986176,-0.11438860013658138), NE * labelscalefactor); dot((0,0),linewidth(3pt) + dotstyle); label("$P_{0}$", (0.030477197571821518,-0.10996323039394912), NE * labelscalefactor); dot((0.9651456265998052,0.8778131465827721),linewidth(3pt) + dotstyle); label("$P_{2016}$", (0.7960661630472025,0.9056591255401539), NE * labelscalefactor); dot((1.5,1.143459684030476),linewidth(3pt) + dotstyle); label("$P_{2017}$", (1.5594424436512673,1.0539090119183345), NE * labelscalefactor); dot((2,1.5095335710010926),linewidth(3pt) + dotstyle); label("$P_{2018}$", (1.8338153676944673,1.5539757928357796), NE * labelscalefactor); dot((2,1.391795072744722),linewidth(3pt) + dotstyle); label("C", (2.0241062666276544,1.303942402377057), NE * labelscalefactor); dot((0,0.04523802311862646),linewidth(3pt) + dotstyle); label("A", (-0.08458241573661723,0.051562765212128256), NE * labelscalefactor); dot((0,0.398453517887737),linewidth(3pt) + dotstyle); label("B", (0.02383914295787313,0.3281483741266443), NE * labelscalefactor); dot((0,0.448453517887737),linewidth(3pt) + dotstyle); label("D", (-0.0804914295787313,0.4381483741266443), NE * labelscalefactor); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); /* end of picture */[/asy][/asy] Because $P_{2017}$ and $P_{2018}$ differ by 1 on $x$ coordinates, $a_{2018}-a_{2017}$ equals $y$ value of $\overrightarrow{CP_{2018}}$. Using $ABP_{2017}\sim P_{2017}CP_{2016}$, $\overrightarrow{CP_{2018}} = \frac{\overrightarrow{AB}}{2017}$. $A$ and $B$ are on line $P_0D$. $P_0D = \frac{p_{2016}}{2017}$ and $p_{2016}$'s maximum value is $2016$ when $a_1 = a_2 = \dots = a_{2016} = 1$(Or in our graph, when $P_0, P_1, P_{2016}$ are collinear). And so the answer is $\frac{2016}{2017^2}$
15.06.2020 05:27
The main claim is the following: Claim: We have $\frac{a_{n-1}+\cdots+a_0}n\le a_n\le\frac{a_{n-1}+\cdots+a_1}{n-1}.$ Proof: Just induction. $\blacksquare$ From this we have \begin{align*} 2017a_{2018}-a_{2017}&\le a_{2016}+\cdots+a_1\\ -2016a_{2017}&\le\frac{-2016}{2017}(a_{2016}+\cdots+a_0)\\ \implies a_{2018}-a_{2017}&\le \frac{1}{2017^2}(a_{2016}+\cdots+a_1)\\ &\le \frac{1}{2017^2}\frac{2016}{2015}(a_{2015}+\cdots+a_1)\\ &\le\frac{1}{2017^2}\frac{2016}{2014}(a_{2014}+\cdots+a_1)\\ &\vdots\\ &\le\frac{2016}{2017^2}. \end{align*}We have equality when $a_1=a_2=\cdots=a_{2016}=1,a_{2017}=2016/2017,a_{2018}=1-1/2017^2.$
16.09.2020 03:33
For each $n$, let $k(n)$ be the maximal $k$ such that \[a_n=\frac{a_{n-1}+\cdots+a_{n-k}}{k}.\]For each $n$, let \[m_n=\min_{1\le k\le n}\frac{a_{n-1}+\cdots+a_{n-k}}{k},M_n=\max_{1\le k\le n}\frac{a_{n-1}+\cdots+a_{n-k}}{k}.\] Claim: When $a_{2018}-a_{2017}$ is minimized or maximized, $a_n \in \{m_n,M_n\}$ for each $n$. Solution: Consider a particular $n$ where $a_{2018}-a_{2017}$ is maximized or minimized. Fix the $k(n')$ for $n'\ne n$. Note that $a_{2018}-a_{2017}$ is linear in $a_n$, so the minima and maxima of $a_{2018}-a_{2017}$ occur when $a_n\in\{m_n,M_n\}$. $\fbox{}$ Claim: For each $n$, we have \[m_n=\frac{a_0+\cdots+a_{n-1}}{n},M_n=\frac{a_1+\cdots+a_{n-1}}{n-1}.\] Solution: Induct on $n$. The claim is obvious for $n=2$. Induction Step: We have two cases, either $a_n=m_n$ or $a_n=M_n$. Note that \[m_n = \min \left(\frac{a_0+\cdots+a_{n-1}}{n-1},a_n\right)\]by the induction hypothesis. If $a_n=M_n$ we are done, otherwise note the two expressions are equal. A similar argument applies for $M_n$. $\fbox{}$ Now, define $\Delta_n = M_n-m_n$. If we have $a_n=m_n$, then \[m_{n+1}=m_n,M_{n+1}=\frac{m_n + (n - 1)M_n}{n}\qquad\mbox{and}\qquad \Delta_{n+1}=\frac{n - 1}{n}\Delta_n.\]If we have $a_n=M_n$, then \[m_{n+1}=\frac{n\cdot m_n+M_n}{n+1},M_{n+1}=M_n\qquad\mbox{and}\qquad \Delta_{n+1}=\frac{n}{n+1}\Delta_n.\]Now, note that for a fixed value of $a_1,\dots,a_{2017}$, $a_{2018}-a_{2017}$ is maximized when $a_{2018}=M_{2018}$ and minimized when $a_{2018}=m_{2018}$. First, we compute an upper bound bound on $a_{2018}-a_{2017}$, taking $a_{2018}=M_{2018}$. Note that this expression can be written as \[\frac{a_1+\cdots+a_{2017}}{2017}-a_{2017} = \frac{a_1+\cdots+a_{2016}}{2017} - \frac{2016}{2017}a_{2017} \le \frac{2016}{2017}M_{2017} - \frac{2016}{2017}m_{2017} = \frac{2016}{2017}\Delta_{2017}.\]Similarly, if we take $a_{2018}=m_{2018}$, we can write \[\frac{a_0+\cdots+a_{2017}}{2018}-a_{2017} = \frac{a_0+\cdots+a_{2016}}{2018} - \frac{2017}{2018}a_{2017} \ge \frac{2017}{2018}m_{2017}-\frac{2017}{2018}M_{2017} = -\frac{2017}{2018}\Delta_{2017}.\]It now suffices to compute a sharp bound on $\Delta_{2017}$, from which we can extract the equality cases. Note \[\Delta_{2017}\le \frac{2016}{2017}\Delta_{2016} \le \cdots \le \frac{2016}{2017}\cdot\frac{2015}{2016}\cdots\frac{2}{3}\Delta_2=\frac{2}{2017}\Delta_2 = \frac{2}{2017}\left|1-\frac{1}{2}\right| = \frac{1}{2017},\]which extracts both the equality cases and yields the bound \[-\frac{1}{2018}\le a_{2018}-a_{2017}\le \frac{2016}{2017^2}.\]
15.11.2020 11:02
Very nice linear inequality problem. Turns out to be much, much weaker than I first expected. The answer is $\boxed{a_{2018}-a_{2017}\leq \dfrac{2016}{2017^2}}$. Construction is easy, just pick $a_{i} = 1$ for each $1 \leq i \leq 2016$, and $(a_{2017},a_{2018}) = \left(\dfrac{2016}{2017}, \dfrac{2016\cdot 2017+2016}{2017^2}\right)$ This proof is divided into two parts, as we only focus on the values of $a_{2017}$ and $a_{2018}$ in the first part, while we finish the problem on the second part. ${\color{green}\rule{25cm}{3pt}}$ $\textcolor{blue}{\textbf{\text{Part 1.}}}$ We replace $2017$ by $n$. First, out of a fixed sequence $a_0,a_1,\ldots,a_{n-1}$ we determine the (uniquely determined) value of $a_{n}$ for the highest difference of $a_{n+1}-a_n$: $\textbf{Claim 1: Smoothing.}$ For the best results, \[a_n = min\left( \dfrac{a_{n-1}+\ldots+a_{n-k}}{k}\right)\]$\textbf{Proof 1.}$ For ease of writeup, we let the sum $\dfrac{a_{n-1}+\ldots+a_{n-k}}{k}$ to be $c_{k}$. Let $a_n = A = c_l$ for some $1 \leq l \leq n$. Now we basically take the advantage of $a_{n+1}-a_n$'s linearity as following: Now, we let \begin{align*} a_{n+1} &= \dfrac{a_n+a_{n-1}+\ldots+a_{n-m}}{m+1} = \dfrac{a_n}{m+1}+\dfrac{a_{n-1}+\ldots+a_{n-m}}{m+1} \\ a_{n+1}-a_n &= \dfrac{a_{n-1}+\ldots+a_{n-m}}{m+1} + \dfrac{a_n}{m+1} - a_n \\ &= \dfrac{a_{n-1}+\ldots+a_{n-m}}{m}\dfrac{m}{m+1} - a_n \dfrac{m}{m+1} \\ &= \dfrac{m}{m+1} \left(\dfrac{a_{n-1}+\ldots+a_{n-m}}{m} - a_n\right) \end{align*}Then, whatever $m$ we end up picking, $a_n = A$ must be the least among all $c_l$, i.e. the minimum we describe in the beginning of $\textbf{Claim 1.}$ $\hfill \blacksquare$ ${\color{red}\rule{25cm}{0.5pt}}$ $\textcolor{green}{\textbf{\text{Transition.}}}$ We know that the two highest values of $\dfrac{m}{m+1}$ are $\dfrac{n-1}{n}$ and $\dfrac{n}{n+1}$. We also know that at its best, $\dfrac{a_{n-1}+\ldots+a_{n-m}}{m}$ is $\max(c_k), \ 1\leq k \leq n$. So, if we have proven that $max(c_k)-min(c_l) \leq \dfrac{1}{n}, \ 1\leq k,l \leq n$, and we have eliminated the case when $\dfrac{m}{m+1} = \dfrac{n}{n+1}$, we are done. (Two job descriptions, as it may seem, but the next part trivializes the whole thing!) ${\color{red}\rule{25cm}{0.5pt}}$ $\textcolor{blue}{\textbf{\text{Part 2.}}}$ Now we focus on the earlier parts of the sequence. Motivated by the equality case and the result we have proven on the $\textcolor{green}{\textbf{\text{Transition.}}}$ ($m$ should be $n-1$ for equality to actually happen), we will claim: $\textbf{Claim 2.}$ Given a partial sequence $a_0,a_1,\ldots,a_{p-1}$ satisfying the problem condition, then if $M_p$ and $m_p$ are the maximum and minimum of $c_k = \dfrac{a_{p-1}+a_{p-2}+\ldots+a_{p-k}}{k}, 1\leq k\leq p$, then \[ M_p = c_{p-1}, \ \text{and} \ m_p = c_p. \]$\textbf{Proof 2.}$ Proceed by induction. The idea is we revert back to the sequence when $a_{p-1}$ is not yet constructed; letting $d_l, 0\leq l\leq p-1$ in a similar manner as $c_k$ but with $a_0$ until $a_{p-2}$ yields \[ d_{p-1} \leq a_{p-1} = d_q \leq d_{p-2} \]for some $q$. Then, it is "easy" (by force-computing for $d_{p-2}$ and $d_{p-1}$ to appear) to see that \begin{align*} c_k = \dfrac{a_{p-1}+a_{p-2}+\ldots+a_{p-k}}{k} &= \dfrac{a_{p-1}+(k-1)d_{k-1}}{k} \\ &\leq \dfrac{a_{p-1}+(k-1)d_{p-2}}{k} \\ &\leq \dfrac{\frac{k}{p-1}a_{p-1}+\frac{p-1-k}{p-1}d_{p-2}+(k-1)d_{p-2} }{k} \\ &= \dfrac{\frac{k}{p-1}a_{p-1}+ \frac{k(p-2)}{p-1}d_{p-1}}{k} \\ &= \dfrac{1}{p-1}a_{p-1} + \dfrac{p-2}{p-1} d_{p-1} \\ &= c_{p-1}. \\ c_k = \dfrac{a_{p-1}+a_{p-2}+\ldots+a_{p-k}}{k} &\geq \dfrac{a_{p-1}+(k-1)d_{p-1}}{k}\\ &\geq \dfrac{ \frac{k}{p}a_{p-1}+\frac{p-k}{p}d_{p-1}+(k-1)d_{p-1}}{k} \\ &= \dfrac{ \frac{k}{p}a_{p-1} + \frac{k(p-1)}{p}d_{p-1}}{k} \\ &= \dfrac{1}{p}a_p + \dfrac{p-1}{p}d_{p-1} \\ &= c_p \end{align*}(in the first inequality assume $k \leq p-1;$ if $k = p$ note that $a_0 = 0$ hence $c_p$ must be smaller than $c_{p-1}$.) We are done. ${\color{green}\rule{25cm}{3pt}}$ $\textcolor{red}{\textbf{\text{Finalising.}}}$ Note that the expression of $a_{n+1}-a_n$ in $\textcolor{blue}{\textbf{\text{Part 1.}}}$ is equal to \[ \dfrac{m}{m+1} \left(\dfrac{a_{n-1}+\ldots+a_{n-m}}{m} - m_n\right) \]If $m = n$, then the expression is equal to $\dfrac{n}{n+1} \cdot 0$, as $\dfrac{a_{n-1}+\ldots+a_{n-m}}{m} = m_n$ when $m = n$. To compute $M_n - m_n = c_{n-1}-c_n$, just note that $c_{n-1} = \dfrac{0+a_1+\ldots+a_{n-1}}{n-1}$ and $c_n = \dfrac{a_1+\ldots+a_{n-1}}{n}$, and since $a_i \leq 1$, then the expression is at most \[ \dfrac{a_1+\ldots+a_{n-1}}{n(n-1)} \leq \dfrac{n-1}{n(n-1)} = \dfrac{1}{n}. \]We are done.
16.02.2021 04:44
Solved with nukelauncher. The answer is \(\frac{2016}{2017^2}\), achieved by \(a_0=0\), \(a_1=a_2=\cdots=a_{2016}=1\), \(a_{2017}=\frac{2016}{2017}\), \(a_{2018}=\frac{2016}{2017}+\frac{2016}{2017^2}\). We now show this is maximal. The following claim is key: Claim: Given \(a_0\), \(a_1\), \ldots, \(a_{n-1}\), over all choices for \(a_n\), the choice \(a_n=\frac{a_{n-1}+\cdots+a_0}n\) is minimal, and the choice \(a_n=\frac{a_{n-1}+\cdots+a_1}{n-1}\) is maximal. Proof. We proceed by induction on \(n\) with the hypothesis that \[\frac{a_{n-1}+\cdots+a_0}n\le a_n=\frac{a_{n-1}+\cdots+a_{n-k}}k\le\frac{a_{n-1}+\cdots+a_1}{n-1}\]for all \(n\), \(k\). Observe that \begin{align*} a_n &=\frac1k\cdot a_{n-1}+\frac{k-1}k\cdot\frac{a_{n-2}+\cdots+a_{n-k}}{k-1}\\ &\stackrel{\text{I-H}}\ge\frac1k\cdot a_{n-1}+\frac{k-1}k\cdot\frac{a_{n-2}+\cdots+a_0}{n-1}\\ &\stackrel{\text{I-H}}\ge\frac1n\cdot a_{n-1}+\frac{n-1}n\cdot\frac{a_{n-2}+\cdots+a_0}{n-1}\\ &=\frac{a_{n-1}+\cdots+a_0}n. \end{align*} Analogously, \begin{align*} a_n &=\frac1k\cdot a_{n-1}+\frac{k-1}k\cdot\frac{a_{n-2}+\cdots+a_{n-k}}{k-1}\\ &\stackrel{\text{I-H}}\le\frac1k\cdot a_{n-1}+\frac{k-1}k\cdot\frac{a_{n-2}+\cdots+a_1}{n-2}\\ &\stackrel{\text{I-H}}\le\frac1{n-1}\cdot a_{n-1}+\frac{n-2}{n-1}\cdot\frac{a_{n-2}+\cdots+a_1}{n-2}\\ &=\frac{a_{n-1}+\cdots+a_1}{n-1}. \end{align*}\(\blacksquare\) Given \(a_0\), \(a_1\), \ldots, \(a_{n-1}\), let \(M_n=\frac{a_{n-1}+\cdots+a_1}{n-1}\) and \(m_n=\frac{a_{n-1}+\cdots+a_0}n\) be the maximum and minimum possible values of \(a_n\). Then \[M_n-m_n=\frac{a_{n-1}+\cdots+a_1}{n-1}-\frac{a_{n-1}+\cdots+a_0}n=\frac{a_{n-1}+\cdots+a_1}{n(n-1)}\le\frac1n.\] Finally, let \(a_{2018}=\frac{a_{2017}+\cdots+a_{2018-k}}k\). Observe that \(k=2018\) is strictly worse than \(k=2017\) by the claim, so \(k\le2017\). It follows that \begin{align*} a_{2018}-a_{2017}&=\frac{k-1}k\left(\frac{a_{2016}+\cdots+a_{2018-k}}{k-1}-a_{2017}\right)\\ &\le\frac{k-1}k(M_{2017}-m_{2017})\le\frac{2016}{2017}\cdot\frac1{2017}=\frac{2016}{2017^2}. \end{align*} Remark: The minimum possible value of \(a_{2018}-a_{2017}\) is \(\frac{-1}{2018}\), achieved by \(a_0=0\), \(a_1=\cdots=a_{2017}=1\), \(a_{2018}=\frac{2017}{2018}\). The bound follows from \[a_{2018}-a_{2017}\ge\frac{k-1}k(m_{2017}-M_{2017})\ge\frac{2017}{2018}\cdot\frac{-1}{2017}=\frac{-1}{2018}.\]
06.06.2021 23:23
Is this too good to be true? Sketch: We claim that the answer is $\frac{2016}{2017^2}$. Claim: $\frac{a_{n-1}+\cdots + a_{n-k}}{k}.$ is maximized when $k=n-1$. Proof: Relatively simple induction. Claim: $\frac{a_{n-1}+\cdots + a_{n-k}}{k}.$ is minimized when $k=n$. Proof: Very similar to the proof of the previous claim. Also, notice that $a_{2018}-a_{2017}$ is maximized when $a_{2017}$ is minimized and $a_{2018}$ is maximized (a couple small details to prove here). Thus, $a_{2017}=\frac{a_{2016}+a_{2015}+\cdots + a_0}{2017}$ and $a_{2018}=\frac{a_{2017}+a_{2016}+\cdots + a_1}{2017}$, so $$a_{2018}-a_{2017}=\frac{a_{2017}}{2017}=\frac{a_{2016}+a_{2015}+\cdots + a_0}{2017^2}.$$This is maximized when $a_2=a_3=\dots=a_{2016}=1$, and the maximum value is $\frac{2016}{2017^2}$.
01.08.2021 02:04
The answer is $\frac{2016}{2017^2}$, achieved at $a_x=1$ for $0<x<2017, a_{2017}=\frac{2016}{2017}, a_{2018}=\frac{2017^2-1}{2017}.$ The following two claims are the crux of the problem: Claim 1: each $a_n$ is minimized at $k=n$. Proof: suppose FTSOC that some $a_n$ is uniquely minimized at $k\neq n$. Let $b$ be the minimal such $n$, then $a_{b-k}$ is equal to at least the average of the terms before it by our assumption, and $a_{b-k+1}$ is equal to at least the average of $a_{b-k}$ and every term before it, or equal to $a_{b-k}$, and so on. We will arrive at the same average as $k=0$. Claim 2: each $a_n$ is maximized at $k=n-1$. Proof: similar to above. Fix $a_2,a_3\ldots a_{2017}$; we obviously need to maximize $a_{2018}$, and since then the coefficient of $a_{2017}$ in $a_{2018}-a_{2017}$ is $-\frac{2016}{2017}<0$, we also to minimize $a_{2017}$. We have $a_{2018}=\frac{a_{2017}+a_{2016}+\cdots + a_1}{2017}$ and $a_{2017}=\frac{a_{2016}+a_{2015}+\cdots + a_0}{2017}$, hence their difference is $\frac{a_{2017}}{2017}$; it's easy to see that the maximum possible value of $\text{min}(a_{2017})$ is $\frac{2016}{2017}$, finishing the problem.
16.08.2021 08:03
Basically, the sequence is defined so that each term in the sequence is the average of the $k$ terms before it some $k$. For each term $a_i$ let $M_i, m_i$ be its maximum and minimum possible values. Note that\[a_n = \frac{a_{n-1}}{k} + \frac{k-1}{k}\left(\frac{a_{n-2} + \ldots + a_{n-k}}{k-1}\right) \geq \frac{a_{n-1}}{k} + \frac{(k-1)m_{n-1}}{k} \geq \frac{a_{n-1}}{n} + \frac{(n-1)m_{n-1}}{n}\]since $a_{n-1} \geq m_{n-1}$ and shifting the weights of the weighted average towards $m_{n-1}$ cannot increase the value. Similarly,\[a_n = \frac{a_{n-1}}{k} + \frac{k-1}{k}\left(\frac{a_{n-2} + \ldots + a_{n-k}}{k-1}\right) \leq \frac{a_{n-1}}{k} + \frac{(k-1)M_{n-1}}{k} \leq \frac{a_{n-1}}{n} + \frac{(n-1)M_{n-1}}{n}\]since $a_{n-1} \leq M_{n-1}$ and shifting the weights of the weighted average towards $M_{n-1}$ cannot decrease the value. Clearly $M_2 = a_1$ and $m_2 = \tfrac{a_1 + a_0}{2}$ so we can inductively show that $M_n = \tfrac{a_{n-1} + \ldots + a_1}{n-1}$ and $m_n = \tfrac{a_{n-1} + \ldots + a_0}{n}$. Now, note that\[a_{2018} - a_{2017} = \frac{a_{2017} + \ldots + a_{2018 - k}}{k} - a_{2017} = \frac{k-1}{k}\left(\frac{a_{2016} + \ldots + a_{2018 - k}}{k-1} - a_{2017}\right).\]We want to find the $k$ that maximize and minimize this. Minimizing is easy; this is at least $\tfrac{k-1}{k}\left(m_{2017} - M_{2017}\right)$ but\[M_{2017} - m_{2017} = \frac{a_{2016} + \ldots + a_0}{2017 \cdot 2016} \leq \frac{1}{2017}\]and $\tfrac{k-1}{k} \leq \tfrac{2017}{2018}$ because $k \leq 2018$, since $a_0 = 0$ and for every $a_i$ where $i$ is positive, $a_i \leq 1$ which can easily be shown by induction. Thus $\min{(a_{2018} - a_{2017})} = -\tfrac{1}{2018}$. Maximizing is similar, but we need to be careful that $k = 2018$ is clearly not optimal since that results in negative $a_{2018} - a_{2017}$. Therefore,\[a_{2018} - a_{2017} \leq \frac{2016}{2017}(M_{2017} - m_{2017}) \leq \frac{2016}{2017^2}. \]We inductively construct the equality cases to be $a_0 = 0, a_1 = \ldots = a_{2016} = 1$, $a_{2017} = m_{2017}$ and $a_{2018} = M_{2018}$ to attain the maximum and $a_0 = 0, a_1 = \ldots = a_{2017} = 1$ while $a_{2018} = m_{2018}$ to attain the minimum.
12.01.2022 21:37
We will prove by induction that if $a_0$, $a_1$, $\ldots$, $a_{i-1}$ are fixed, then the minimum value of $a_i$ is $\frac{a_0+a_1+\ldots+a_{i-1}}i$, and the maximum value of $a_i$ is $\frac{a_1+\ldots+a_{i-1}}{i-1}$. Base Case: $i=2$ The minimum value of $a_2$ is $\frac12=\frac{0+1}2$, and the maximum value of $a_2$ is $1=\frac11$. Inductive Step: Suppose that $$\frac{a_{i-1}+a_{i-2}+\ldots+a_k}{i-k}<\frac{a_0+a_1+\ldots+a_{i-1}}i.$$Then, we must have $$k(a_k+a_{k+1}+\ldots+a_{i-1})<(i-k)(a_0+a_1+\ldots+a_{k-1}).$$However, by the inductive hypothesis, $a_j\geq\frac{a_0+a_1+\ldots+a_{j-1}}j$. If $j\geq k$, then this means that $a_j\geq\frac{a_0+a_1+\ldots+a_{k-1}}k$, which is a contradiction by adding the equations for $k\leq j<i-1$. Similarly, suppose that $$\frac{a_{i-1}+a_{i-2}+\ldots+a_k}{i-k}>\frac{a_1+a_2+\ldots+a_{i-1}}{i-1}.$$Then, we must have $$(k-1)(a_k+a_{k+1}+\ldots+a_{i-1})<(i-k)(a_1+a_2+\ldots+a_{k-1}).$$However, by the inductive hypothesis, $a_j\leq\frac{a_1+a_2+\ldots+a_{j-1}}j$. If $j\geq k$, then this means that $a_j\leq\frac{a_1+a_2+\ldots+a_{k-1}}k$, which is a contradiction by adding the equations for $k\leq j<i-1$. Therefore, $\frac{a_0+a_1+\ldots+a_{i-1}}i\leq a_i\leq\frac{a_1+a_2+\ldots+a_{i-1}}{i-1}$. Then, we have \begin{align*} a_{2018}-a_{2017}&\geq\frac{a_0+a_1+\ldots+a_{2016}-2017a_{2017}}{2018}\\ &\geq\frac{a_1+a_2+\ldots+a_{2016}-\frac{2017}{2016}(a_1+a_2+\ldots+a_{2016}}{2018}\\ &=-\frac{a_1+a_2+\ldots+a_{2016}}{2016\cdot2018}\\ &\geq-\frac{2016}{2016\cdot2018}\\ &=-\frac1{2018}. \end{align*}Therefore, $a_{2018}-a_{2017}\geq-\frac1{2018}$. Equality is achieved when $a_1=a_2=\ldots=a_{2017}=1$ and $a_{2018}=\frac{2017}{2018}$. Similarly, we get \begin{align*} a_{2018}-a_{2017}&\leq\frac{a_1+a_2+\ldots+a_{2016}-2016a_{2017}}{2017}\\ &\leq\frac{a_1+a_2+\ldots+a_{2016}-\frac{2016}{2017}(a_0+a_1+\ldots+a_{2016}}{2017}\\ &=\frac{a_1+a_2+\ldots+a_{2016}}{2017^2}\\ &\leq\frac{2016}{2017^2}. \end{align*}Therefore, $a_{2018}-a_{2017}\leq\frac{2016}{2017^2}$. Equality is achieved when $a_1=a_2=\ldots=a_{2016}=1$, $a_{2017}=\frac{2016}{2017}$, and $a_{2018}=\frac{2017^2-1}{2017^2}$. Therefore, the minimum value of $a_{2018}-a_{2017}$ is $\boxed{-\frac1{2018}}$, and the maximum value of $a_{2018}-a_{2017}$ is $\boxed{\frac{2016}{4068289}}$.
27.01.2022 17:22
25.04.2022 21:33
09.05.2022 00:12
We claim that the answer is $\frac{2016}{2017^2}$, which can be achieved by $a_0 = 0, \quad a_1 = \dots = a_{2016} = 1, \quad a_{2017} = 1 - \frac{1}{2017}, \quad a_{2018} = 1 - \frac{1}{2017^2}.$ To prove that is optimal, let $s_n=a_n+a_{n-1}+...+a_2+a_1$. We will prove that $\frac{s_n}{n} \geq \frac{s_{n+1}}{n+1}$ for all $n$. We use strong induction on $n$, the case $n=1$ is trivial. From the problem, there exists a $k \leq n$ such that $s_{n+1}-s_n=\frac{s_n-s_{n-k}}{k} \implies s_{n+1}=s_n+\frac{s_n-s_{n-k}}{k} \implies \frac{s_{n+1}}{n+1}=\frac{s_n}{n+1}+\frac{s_n-s_{n-k}}{k(n+1)}$. Thus, $\frac{s_{n+1}}{n+1} \leq \frac{s_n}{n} \iff \frac{s_n}{n+1}+\frac{s_n-s_{n-k}}{k(n+1)} \leq \frac{s_n}{n} \iff \frac{s_n}{n(n+1)} \geq \frac{s_n-s_{n-k}}{k(n+1)} \iff \frac{s_n}{n} \geq \frac{s_n-s_{n-k}}{k} \iff \frac{s_{n-k}}{k} \geq \frac{s_n(n-k)}{kn} \iff \frac{s_{n-k}}{n-k} \geq \frac{s_n}{n}$, which is true by inductive hypothesis. Now, we prove that $\frac{s_n}{n+1} \geq \frac{s_{n-1}}{n}$ for all $n$. We use strong induction on $n$, the case $n=2$ is trivial. From the problem, there exists a $k \leq n$ such that $s_{n+1}-s_n=\frac{s_n-s_{n-k}}{k} \implies s_{n+1}=s_n+\frac{s_n-s_{n-k}}{k} \implies \frac{s_{n+1}}{n+2}=\frac{s_n}{n+2}+\frac{s_n-s_{n-k}}{k(n+2)}$. Thus, $\frac{s_{n+1}}{n+2} \geq \frac{s_n}{n+1} \iff \frac{s_n}{n+2}+\frac{s_n-s_{n-k}}{k(n+2)} \geq \frac{s_n}{n+1} \iff \frac{s_n-s_{n-k}}{k(n+2)} \geq \frac{s_n}{(n+1)(n+2)} \iff \frac{s_n-s_{n-k}}{k} \geq \frac{s_n}{n+1} \iff \frac{s_n(n+1-k)}{(n+1)k} \geq \frac{s_{n-k}}{k} \iff \frac{s_n}{n+1} \geq \frac{s_{n-k}}{n-k+1}$, which is true by inductive hypothesis. Both results imply that $\frac{s_n}{n} \geq a_{n+1} \geq \frac{s_n}{n+1}$. Therefore, $$a_{n+1}-a_n \leq \frac{s_n}{n}-a_n=\frac{s_{n-1}-(n-1)a_n}{n} \leq \frac{s_{n-1}-(n-1)\frac{s_{n-1}}{n}}{n}=\frac{s_{n-1}}{n^2} \leq \frac{n-1}{n^2}$$so the result follows for $n=2017$. $\blacksquare$
29.12.2022 22:59
I believe this problem relies much more on intuition than computation/technical details; as such, I will be lazy and omit technical details. Essentially, varying any term $a_i$ over all its possible values linearly varies $a_{2018}-a_{2017}$. As we're only interested in the maximum and minimum, all $a_i$ have to be either its maximum or minimum possible value. Also, note that if two consecutive values are both either their maximum or minimum, then they have to be the same. With some technical details, you can induct to get that any $a_i$ achieves its maximum when it is the average of $a_1, \cdots a_{i-1}$, and achieves its minimum when it is the average of $a_0, \cdots a_{i-1}$. Minimum: Clearly, $a_{2017}$ attains its minimum value, and $a_{2018}$ attains its maximum. Calculations yield that $a_{2018} - a_{2017} = -\frac{\sum_{i=0}^{2016}a_i }{2018\cdot 2016}\ge -\frac{1}{2018}.$ Equality occurs when $a_i=1$ for $1 \le i \le 2016$. Maximum: Clearly, $a_{2017}$ attains its maximum value, and $a_{2018}$ attains its minimum. Calculations yield that $a_{2018} - a_{2017} = \frac{\sum_{i=0}^{2016}a_i }{2017^2}\le \frac{2016}{2017^2}.$ Equality occurs when $a_i=1$ for $1 \le i \le 2016$.
13.02.2023 06:11
The answer is $\frac{2016}{2017^2}$. This is achievable by setting $a_2, a_3, \dots, a_{2016} = 1$ by choosing $k=1$, $a_{2017} = \frac{2016}{2017}$ by choosing $k=2017$, and $a_{2018} = \frac{2017^2 - 1}{2017^2}$ by choosing $k=2017$. Define \[l_i = \min_{k=1}^{i+1} \frac{a_i + a_{i-1} + \dots + a_{i-k+1}}{k},\]and similarly \[r_i = \max_{k=1}^{i+1} \frac{a_i + a_{i-1} + \dots + a_{i-k+1}}{k}.\]Clearly we have $l_i \le a_{i+1} \le r_i$ for $i \ge 1$. Claim: For all $i \ge 1$, $r_i - l_i \le \frac{1}{i+1}$. Proof: Use induction on $i$. The base case follows from $l_1 = \frac12$ and $r_1 = 1$. Suppose $r_{i-1} - l_{i-1} \le \frac{1}{i}$. Then $l_{i-1} \le a_i \le r_{i-1}$. Then, to bound $l_i$, consider a segment $a_{i-k+1}, a_{i-k+2}, \dots, a_i$ of $a$ ending at $a_i$, whose average is minimal (in other words, equal to $l_i$). This average is the weighted average of $x = \frac{a_{i-k+1} + a_{i-k+2} + \dots + a_{i-1}}{k-1}$, with weight $k-1$, and $a_i$, with weight 1, so $l_i = \frac{(k-1)x + a_i}{k}$. But $x \ge l_{i-1}$, giving $l_i \ge \frac{(k-1)l_{i-1} + a_i}{k}$. In addition, since $a_i \ge l_{i-1}$, increasing the weight of $l_{i-1}$ from $k-1$ to $i$ (the maximum possible, since $k \le i+1$) in the weighted average can only decrease the RHS of this inequality. Therefore we have \[l_i \ge \frac{il_{i-1} + a_i}{i+1}.\]We can bound $r_i$ in a similar function, but we can get an even stronger bound because we can assume that the segment $a_{i-k+1}, a_{i-k+2}, \dots, a_i$ does not contain $a_0 = 0$ (since including it can only decrease the average, which we want to maximize), so $k \le i$ and the result can be written as \[r_i \le \frac{(i-1)r_{i-1} + a_i}{i} \le \frac{ir_{i-1} + a_i}{i+1}.\]Adding $\frac{il_{i-1} + a_i}{i+1} \le l_i$ and $r_i \le \frac{ir_{i-1} + a_i}{i+1}$, we have $r_i - l_i \le \frac{i}{i+1}(r_{i-1} - l_{i-1})$, which gives the desired conclusion using the inductive hypothesis. $\square$ To finish, we have \[a_{2018} - a_{2017} \le r_{2017} - a_{2017} \le \frac{2016r_{2016} + a_{2017}}{2017} - a_{2017} = \frac{2016}{2017}(r_{2016} - a_{2017}) \le \frac{2016}{2017}(r_{2016} - l_{2016}) \le \frac{2016}{2017^2},\]as desired.
06.03.2023 06:58
We define a function $s(k_2,k_3,\dots, k_{2018})$ taking in $2017$ integer values and outputting a sequence $a_0,a_1,\dots $ such that the function is defined by \[a_n=\frac{a_{n-1}+\dots + a_{n-k_n}}{k_n}.\]Assume that $a_{2018}-a_{2017}$ is at its maximal value. We will keep $k_2,k_3,\dots,k_{2018}$ all the same, except for one of them, $k_i$. Note that $a_{2018}-a_{2017}$ will be a linear function in $a_{i}$. Therefore, when $a_{2018}-a_{2017}$ is at its maximum, $a_i$ must also be at its local maximum or minimum. $~$ Now that we have established the conditions for maximality, we can inductively show that $a_i$ is maximized when we use $k_i=i-1$ and minimized when we use $k_i=i$. Now, note that $a_{2018}-a_{2017}$ is maximized when $a_{2018}$ is maximized and $a_{2017}$ minimized we can check those values based on what we have above to be \[\frac{a_{2016}+\dots + a_0}{2017^2}\le \frac{2016}{2017^2}\]
15.03.2023 17:14
The answer is $\frac{2016}{2017^2}$. Let $A(n,k)$ denote the average of the $k$ terms preceding $a_n$, i.e. $$A(n,k)=\frac{a_{n-1}+\cdots+a_{n-k}}{k}.$$For a construction that achieves the maximal value, take $a_2=\cdots=a_{2016}=1$ (so $a_i=A(i,1)$ for $2 \leq i \leq 2016$), $a_{2017}=A(2017,2017)=\frac{2016}{2017}$, and $a_{2018}=A(2018,2017)=\frac{2016\cdot 2018}{2017^2}$. The key claim is the following general fact about the sequence. Claim: For all $n \geq 2$, we have $A(n,n) \leq a_n \leq A(n,n-1)$. Proof: We will inductively prove that we have $A(n,n) \leq A(n,i) \leq A(n,n-1)$ for all $1 \leq i \leq n$ by induction on $n$, which is equivalent, with the base case of $n=2$ being trivial. For the inductive step, note that we have $$iA(n,i)=a_{n-1}+\cdots+a_{n-i}=a_{n-1}+(i-1)A(n-1,i-1).$$For the lower bound, $$a_{n-1}+(i-1)A(n-1,i-1) \geq a_{n-1}+(i-1)A(n-1,n-1)=a_{n-1}+\frac{i-1}{n-1}(a_{n-2}+\cdots+a_0).$$Then we have \begin{align*} a_{n-1}+\frac{i-1}{n-1}(a_{n-2}+\cdots+a_0)&\geq iA(n,n)=\frac{i}{n}(a_{n-1}+\cdots+a_0) &\iff\\ \frac{n-i}{n} a_{n-1}&\geq \left(\frac{i}{n}-\frac{i-1}{n-1}\right)(a_{n-2}+\cdots+a_0)=\frac{n-i}{n(n-1)}(a_{n-2}+\cdots+a_0) &\iff\\ a_{n-1} &\geq \frac{a_{n-2}+\cdots+a_0}{n-1}=A(n-1,n-1), \end{align*}which is true. The upper bound is similar. We have $$a_{n-1}+(i-1)A(n-1,i-1) \leq a_{n-1}+(i-1)A(n-1,n-2)=a_{n-1}+\frac{i-1}{n-2}(a_{n-2}+\cdots+a_1),$$and then \begin{align*} a_{n-1}+\frac{i-1}{n-2}(a_{n-2}+\cdots+a_1)&\leq iA(n,n-1)=\frac{i}{n-1}(a_{n-1}+\cdots+a_1) &\iff\\ \frac{n-i-1}{n-1}a_{n-1}&\leq \left(\frac{i}{n-1}-\frac{i-1}{n-2}\right)(a_{n-2}+\cdots+a_1)=\frac{n-i-1}{(n-1)(n-2)}(a_{n-2}+\cdots+a_1) &\iff\\ a_{n-1} &\leq \frac{a_{n-2}+\cdots+a_1}{n-2}=A(n-1,n-2), \end{align*}which is also true. $\blacksquare$ To finish the problem, note that the coefficient of $a_{2017}$ in $a_{2018}-a_{2017}=A(2018,k)-a_{2017}$ (for some $k$) is nonpositive, so we should make $a_{2017}$ as small as possible, i.e. equal to $A(2017,2017)$. Then we should make $a_{2018}$ as big as possible, i.e. $A(2018,2017)$, to maximize the difference. Since $$A(2018,2017)-A(2017,2017)=\frac{1}{2017}a_{2017}=\frac{1}{2017}A(2017,2017)=\frac{a_{2016}+\cdots+a_0}{2017^2},$$and $a_{2016}+\cdots+a_0=a_{2016}+\cdots+a_1\leq 2016$ (it is clear that $a_i \in [0,1]$ by induction for $i\geq 1$), the given bound is optimal. $\blacksquare$
26.09.2023 17:15
I claim the answer is $\frac{2016}{2017^2}$, which is achievable with the sequence $a_i=1$ for $1 \le i \le 2016$, $a_{2017}=\frac{2016}{2017}$, and $a_{2018}=\frac{2016+\frac{2016}{2017}}{2017}$. To prove this, first observe if we fix the choice of $k$ for all indices $c \le i \le 2018$, then observe that our function $a_{2018}-a_{2017}$ is linear in the first $c-1$ terms. This means that the optimal value is when each of the first $i$ terms have their $k$ chosen so that their value is either maximal or minimal. We continue all the way up to get that each term is either the largest or smallest possible average of previous terms in the optimal case. Claim: The largest possible average goes all the way back to $a_1$, and the smallest possible average goes all the way back to $a_0$. Proof: we prove this by induction. The base case is trivial Suppose that $a_i$ is the largest possible average, so it goes back to $a_1$. Then the value of $a_{i+1}$ is a weighted average of $a_i$ and some average of the previous terms. If we want to maximize this, we should maximize the average of the previous terms, which means going back to $a_1$, whence $a_i=a_{i+1}$. If we want to minimize this, then going back to $a_0$ is optimal, because it both produces the smallest possible weight on $a_i$, (and $a_i$ must be at least as large as the average of previous terms by construction), and it minimizes the average of previous terms term by induction hypothesis. I now show that the construction I gave earlier is optimal. Clearly, we want $a_{2018}$ to be a maximal average, and we want $a_{2017}$ to be a minimal average in the optimal case (otherwise the score would be at most $0$). This means that our score is $$a_{2018}-a_{2017}=\sum_{i=1}^{2017}\frac{a_i}{2017}-\sum_{i=1}^{2016}\frac{a_i}{2017}$$, which simplifies to $$\frac{a_{2017}}{2017}=\sum_{i=1}^{2016}\frac{a_i}{2017}$$. Now we want to maximize this sum, but it is clearly maximized when $a_i=1$ for $1 \le i \le 2016$, given the result above.
07.07.2024 00:14
Solved with KW, JP, MA, GL, RM, MY, KL, and pyramid__scheme I claim the answer is $\frac{2016}{2017^2}$ achieved with $a_i=1$ for $i \leq 2016$, $a_{2017}=\frac{2016}{2017}$, and $a_{2018}=\frac{2016}{2017}+\frac{2016}{2017^2}$. We now show it's the maximum. Claim: For each $n$, we have \[\frac{\sum_{i=0}^{n-1}a_i}{n} \leq a_n \leq \frac{\sum_{i=1}^{n-1}a_i}{n-1}\]Proof. We induct on $n$ and $k$ with both base cases being obvious. We will show the upper bound on $a_n$; the proof of the lower bound is practically the same algebra. The statement can then be rewritten as for all $k\leq n$, then \begin{align*} & \frac{\sum_{i=1}^{k-1}a_{n-i}}{k} \leq \frac{\sum_{i=1}^n a_i}{n} \\ \iff & n \sum_{i=0}^{k-1}a_{n-i} \leq k \sum_{i=1}^n a_i \\ \iff & (n-k)\sum_{i=0}^{k-1} a_{n-i} \leq k \sum_{i=1}^{n-k}a_i \end{align*}Then, we can say via substitution and inducting down that \begin{align*} (n-k)\sum_{i=0}^{k-1} a_{n-i} &= (n-k)a_n + (n-k)\sum_{i=0}^{k-2}a_{n-1-i} \\ & \leq (n-k)\sum_{i=0}^{k-2}a_{n-1-i} + \frac{n-k}{n-1}\left(\sum_{i=1}^{n-1}a_i \right) \\ & \leq \frac{(n-k)\cdot n}{n-1}\sum_{i=0}^{k-2} + \frac{n-k}{n-1}\left(\sum_{i=1}^{n-k}a_i \right) \\ & \leq \frac{n(k-1)}{n-1} \sum_{i=1}^{n-k}a_i + \frac{n-k}{n-1}\left(\sum_{i=1}^{n-k}a_i \right) \\ & = k \sum_{i=1}^{n-k}a_i \end{align*}as desired. $\blacksquare$ Remark: The fact that the two directions have practically the same algebra in their proof shows the importance of the base cases working out for each inequality. Now, maximize $a_{2018}$ by the claim since it is independent from all others. This gives \[a_{2018}-a_{2017}=\frac{-2016a_{2017}+\sum_{i=1}^{2016}a_i}{2017}\]We now want to minimize $a_{2017}$ which is done by taking it to be $\frac{1}{2017}\sum_{i=1}^{2016}a_i$, leaving us with $\frac{a_{2017}}{2017}$ which we wish to maximize. Since $a_{2017}=\frac{1}{2017}\sum_{i=1}^{2016}a_i \leq \frac{1}{2017} \cdot 2016$ we conclude.
12.07.2024 01:20
It seems like there is something wrong in my solution, because I found a wrong answer. However, if we take $a_1=a_2=\cdots=a_{2016}=1$ and take $a_{2017}=0$ then $a_{2018}=\frac{2016}{2017}$ hence, $a_{2018}-a_{2017}=\frac{2016}{2017}$.
19.08.2024 02:27
We will use "$A(x,y)$" to abbreviate "the average of $a_x, \dots, a_y$". The answer is $\tfrac{2016}{2017^2}$, obtained by setting $a_2$ thru $a_{2016}$ to $1$, setting $a_{2017}$ to $A(0,2016) = \tfrac{2016}{2017}$ and setting $a_{2018}$ to $A(1,2017) = 1 - \tfrac{1}{2017^2}$. For each of $2 \leq i \leq 2016$, we can express $a_{2018} - a_{2017}$ as some linear function of $a_i$ if we fix the definition of all variables except for $a_i$. This means that if we want to maximize $a_{2018} - a_{2017}$, we should either choose $a_i$ to be as large as possible or as small as possible. Claim: For each $i$, $a_i$ is equal to $A(1, i-1)$ if we want to maximize $a_i$, or $A(0,i-1)$ if we want to minimize $a_i$. Proof: We show this with induction on $i$: Base case. Assume that $a_i$ is the lowest-indexed term that we are trying to minimize. Then, we must have been maximizing $a_2, \dots, a_{i-1}$, so they all must be equal to $1$. Evidently, we should set $a_i = A(0,i-1)$. And if $a_j$ is the lowest-indexed term that we are trying to maximize, we must have bene minimizing $a_2, \dots, a_{i-1}$, so they all must equal $\tfrac{1}{2}$. Evidently, we should set $a_i = A(1, i-1)$. Inductive step. Assume the hypothesis holds for $a_2, \dots, a_{i-1}$. Suppose we wish to maximize $a_i$. Let $a_j$ be the most recent index we were trying to maximize previously – by our inductive hypothesis, $A(x,j)$ is maximized when $x=1$. By assumption, we were trying to minimize $a_{j+1}, \dots, a_{i-1}$, so they are at most $a_j$. So, if we are maximizing $A(x,i)$, we can assume $x \leq j$. As such, $A(x,i-1)$ will be a weighted average of $A(x,j)$ and $A(j+1,i-1)$. But we know that $A(x,j)$ is at most $A(1,j)$, and since $A(x,j) \geq A(j+1, i- 1)$, we want to maximize the weight of $A(x,j)$. Thankfully, both maximums are acheived when $x=1$, so $A(x,i-1)$ is maximized at $x=1$. Instead, if we were trying to minimize $a_i$, the reasoning would play out exactly the same so we omit the proof here. To maximize $a_{2018} - a_{2017}$, we want to maximize $a_{2018}$ and minimize $a_{2017}$, so we have that \[a_{2018} - a_{2017} = A(1,2017) - A(0,2016) = \frac{A(0,2016)}{2017} \leq \frac{2016}{2017^2}.\]
20.08.2024 03:56
The answer is $\frac{2016}{2017^2}$, achieved by \[a_0=0,a_1=a_2=\dots,a_{2016}=1,a_{2017}=\frac{2016}{2017},a_{2018}=\frac{2016\cdot 2018}{2017^2}.\] Claim. The "running average" sequence is nondecreasing. Proof. Let the average of $a_0,a_1,\dots,a_n$ be $b_n$. Then we want to show that $b_0\le b_1\le b_2\le\dots$ We will use induction, base case $b_0\le b_1$ is trivial. So assume $b_0\le b_1\le\dots\le b_k$ and we will show $b_k\le b_{k+1}$. This is equivalent to $b_k\le a_{k+1}$. But if $a_{k+1}$ is the average of $a_{x+1}$ up to $a_k$, then since the average of $a_0$ to $a_x$ is at most $b_k$, the average of the rest is at least $b_k$. $\blacksquare$ By a similar reasoning, the "running average except throw out the first $0$" sequence is nonincreasing. Thus for the sequence where $a_{2018}-a_{2017}$ is largest, $a_{2018}$ will be the average of $a_1$ up to $a_{2017}$. Therefore, since $a_{2017}$ has a negative contribution, it will be the minimum possible, thus it is the average of $a_0$ up to $a_{2016}$. Let the sum of $a_0$ up to $a_{2016}$ be $t$, then $a_{2017}=\frac{t}{2017}$ and \[a_{2018}=\frac{t+\frac{t}{2017}}{2017},\]so \[a_{2018}-a_{2017}=\frac{t}{2017^2}\le\frac{2016}{2017^2}\;\blacksquare\]
29.09.2024 12:52
I will prove by induction that the maximal value of $a_n$ is $\frac{a_1+a_2+\dots+a_{n-1}}{n-1}$ and that the minimal value is $\frac{a_0+a_1+a_2+\dots+a_{n-1}}{n}$. Suppose it holds true for $n-1$, thus we get that the maximal value we can attain for $\frac{a_i+a_{i+1}+\dots+a_{n-1}}{n-i-1}$ when $i\neq n-1$ is when $i=1$ and we also get that that value is always at least $\frac{a_{n-1}}{1}$ so we get the result, a similar result holds for minimal. To find the maximal and minimal values of the desired result we get from what we got earlier that they are equivalent to the minimal value of $a_0+a_1+\dots+a_{2016}-2017a_{2017}$ which is clearly minimised when $a_{2017}$ is maximised and thus we get $a_1=\dots=a_2017=1$ which gets us $\frac{-1}{2018}$, and the maximal value of $a_1+a_2+\dots+a_{2016}-2016a_{2017}$, thus we want to minimise $a_2017$ and clearly once we do this we want $a_1=a_2=\dots=a_{2016}=1$ to get us $\frac{2016}{2017^2}$.
30.10.2024 05:51
This problem has legitimately made me hate algebra The minimum difference is $-\frac 1{2018}$, and the maximum difference is $\frac{2016}{2017^2}$. In particular, we make the following claim, which solves the problem: Claim: For every positive integer $n$, \[\frac{a_1+\cdots + a_{n-1}}{n} \leq a_n \leq \frac{a_1+\cdots+a_{n-1}}{n-1}.\] Proof: We prove the stronger result that for any $k \geq 1$, in fact \[\frac{a_1+a_2+\cdots+a_{n-1}}n \leq \frac{a_{n-1} + \cdots + a_{n-k}}k \leq \frac{a_1+a_2+\cdots+a_{n-1}}{n-1}.\]The proof goes by induction on $n$ where we assume the result for all $k$. Note that if $k=1$ the result just reduces to the inductive hypothesis for $n-1$, so assume $k > 1$. Right Inequality: Observe that \begin{align*} \frac{a_{n-1}+a_1+a_2+\cdots+a_{n-2}}{n-1} &= \frac{a_{n-1}}k - \frac{a_{n-1}(n-1-k)}{k(n-1)} + \frac{a_1+a_2+\cdots+a_{n-2}}{n-1} \\ &\geq \frac{a_{n-1}}k - \frac{(n-1-k)(a_1+a_2+\cdots+a_{n-2})}{k(n-1)(n-2)} + \frac{a_1+a_2+\cdots+a_{n-2}}{n-1} \\ &= \frac{a_{n-1}}k + \left(1-\frac{n-1-k}{k(n-2)}\right)\left(\frac{n-2}{n-1}\right)\left(\frac{a_1+a_2+\cdots+a_{n-2}}{n-2}\right) \\ &\geq \frac{a_{n-1}}k + \frac{a_{n-k} + \cdots + a_{n-2}}{k-1} \left(\frac{k-1}k\right) \\ &= \frac{a_{n-1} + a_{n-2} + \cdots + a_{n-k}}k. \end{align*}The proof of the left inequality follows similarly (quite literally analogously: replace $n-1$ with $n$ everywhere and reverse the inequality signs.) $\blacksquare$ To finish the problem, we have \begin{align*} a_{2018} - a_{2017} &\geq \frac{a_1+a_2+\cdots+a_{2016}}{2018} -\frac{2017 a_{2017}}{2018} \\ &\geq \frac{a_1+a_2+\cdots+a_{2016}}{2018} - \frac{2017}{2018} \left(\frac{a_1+a_2+\cdots+a_{2016}}{2016}\right)\\ &= -\frac {a_1+a_2+\cdots+a_{2016}}{2016 \cdot 2018} \geq -\frac 1{2018} \end{align*}as clearly $a_i \leq 1$ for each $i$. For the upper bound, \begin{align*} a_{2018} - a_{2017} &\leq \frac{a_1+a_2+\cdots+a_{2016}}{2017} - \frac{2016 a_{2017}}{2017} \\ &\leq \frac{a_1+a_2+\cdots+a_{2016}}{2017} - \frac{2016}{2017}\left(\frac{a_1+a_2+\cdots+a_{2016}}{2017}\right) \\ &= \frac{a_1+a_2+\cdots+a_{2016}}{2017^2} \leq \frac{2016}{2017^2}. \end{align*}