Let $x, y$ be positive integers such that $x < y < 2x − 1$.
A machine has been making cakes for aperiod of $x$ hours.
The machine made at least one cake per hour and had made less than y cakes in total.
Prove that there is a period of consecutive hours during which the machine made exactly $(2x − y)$ cakes.
I've been stuck with this seemingly easy question for days. Can anyone share some thoughts?
Suppose the machine made $a_i$ cakes during the $i^{th}$ hour, and denote $S_n = a_1 + a_2 + \cdots a_n$. Then $$1 \le S_1 < S_2 < \cdots < S_x \le y-1$$
It's easy to show that $S_{x-1} \le y-2, S_{x-2} \le y-3, \ldots, S_{y-x} \le 2y-2x-1$.
Now consider the following $x+(y-x)=y$ numbers:
$$\text{Group 1: }S_1 < S_2 < \cdots < S_x $$ and
$$\text{Group 2: } S_1 + (2x-y) < S_2 + (2x-y) < \cdots < S_{y-x} + (2x-y) $$
Note that $S_1+1 < S_1+(2x-y), S_{y-x} + (2x-y) \le 2y-2x-1+2x-y=y-1.$
All numbers are between 1 and $y-1$, so there must be two of these numbers having the same value. Since in each group the numbers are distinct so there exist $i, j$ such that $S_i = S_j + 2x-y$, therefore $a_{j+1} + \cdots + a_i = 2x-y$.