4. (Full score: 50 points).

There are $n$ students sitting around a round table for dinner, where $n$ is a given positive integer greater than 1. Each student needs to buy a 50-yuan dinner ticket. Suppose exactly $r(1 \leq r \leq n)$ students have a 100-yuan note, and the rest have 50-yuan notes. Now, waiter Xiao $K$ comes to the round table to sell dinner tickets without any change. If regardless of how the $n$ students are arranged around the table, Xiao $K$ can start from any person and go around the table in any direction (including clockwise and counterclockwise) to sell the dinner tickets, ensuring that all $n$ students can buy the tickets without encountering any change difficulties. Find the maximum value of $r$.

保留源文本的换行和格式，直接输出翻译结果。
IV. Solution: $r_{\max }=\left[\frac{n+1}{3}\right]$

We denote the person holding 50 yuan as 1, and the person holding 100 yuan as -1. The problem is equivalent to arranging $n$ numbers in a circle, where exactly $r$ of them are -1, and the rest are 1. Regardless of how the $n$ numbers are arranged in the circle, starting from a certain number and moving in any direction around the circle, sequentially adding each number, the sum $S_{i}(i=1,2, \mathrm{~L}, n)$ of any $i$ numbers should always be non-negative. We need to find the maximum value of $r$.

Clearly, when $n=2,3$, $r_{\text {max }}=1$; when $n=4$, if $r=2$, then there exists an arrangement $1,1,-1,-1$, such that some $S_{2}=1-1-1<0$, hence $r_{\text {max }}=1$. When $n=5$, if $r=3$, then $S_{5}=-1<0$; if $r=2$, then the only possible arrangements are $1,1,1,-1,-1$ and $1,1,-1,1,-1$. In both arrangements, there is a 1 from which, regardless of the direction, the sum can always be non-negative, so $r_{\max }=2$. Conjecture: $r_{\max }=\left[\frac{n+1}{3}\right]$.

For convenience, we define that if starting from a certain 1 and moving in any direction around the circle, the sum of the numbers is always non-negative, then this 1 is called a "good point."
We now prove that when $3 k-1 \leq n \leq 3 k+1$, $r_{\max }=k$. First, we prove that $r \leq k$.
Assume $r \geq k+1$, since $3 k-1 \leq n \leq 3 k+1$, then the number of 1s on the circle is $n-r \leq 3 k+1-(k+1)=2 k$. On the circle, if all 1s are grouped together and all -1s are grouped together, then for any 1, at least one side of it has no more than $k$ (including itself) 1s. Thus, starting from this 1 and moving in the direction with no more than $k$ 1s, when adding up to the last -1, $S \leq k-(k+1)=-1<0$. Therefore, there are no good points on the circle, i.e., $r \leq k$.
Next, we use induction to prove that when $3 k-1 \leq n \leq 3 k+1$, $r=k$.
We use induction on $k$. When $k=1$, by the previous results, the conclusion holds;
Assume the conclusion holds for $k$, i.e., for $n$ numbers on the circle $(3 k-1 \leq n \leq 3 k+1)$, with at most $k$ -1s and the rest 1s, there must be a good point.

Consider the case for $k+1$, at this point there are $n$ numbers on the circle $(3 k+2 \leq n \leq 3 k+4)$, with at most $k+1$ -1s and the rest 1s. Now, arbitrarily choose a -1, and take one 1 from each side of it that is closest to it, and remove this -1 and these two 1s. Then, among the remaining $n-3$ numbers, there are at most $k$ -1s. Since $3 k-1 \leq n-3 \leq 3 k+1$, by the induction hypothesis, there must be a good point, denoted as $P$.

Now, put the 3 removed points back in their original positions. Since $P$ is not the point closest to the removed -1, when starting from $P$ and moving in any direction around the circle, the sum will first add the 1 that was added back, and then add the -1 that was added back, so the sum remains non-negative. Therefore, $P$ is still a good point, and the conclusion holds for $k+1$.

In summary, $r_{\max }=\left[\frac{n+1}{3}\right]$.