Fix an odd integer $n > 1$. For a permutation $p$ of the set $\{1,2,...,n\}$, let S be the number of pairs of indices $(i, j)$, $1 \le i \le j \le n$, for which $p_i +p_{i+1} +...+p_j$ is divisible by $n$. Determine the maximum possible value of $S$. Croatia
Problem
Source: 2019 RMM Shortlist C3
Tags: combinatorics, divisible, permutation
22.08.2020 08:51
15.05.2022 14:36
The answer is $\frac{(n+3)(n+1)}{8}$, which is obtained at $(n,1,n-1,2,n-2,\cdots, \frac{n-1}{2}, \frac{n+1}{2})$ Remove the element $n$ for now. We first bound the number of pairs $(i,j)$ such that $\lceil \frac i2 \rceil \le \lceil \frac j2 \rceil$. Partition the set of pairs into $\binom{\frac{n+1}{2}}{2}=\frac{n^2-1}{8}$ 2x2 squares, and color a point red if $n|p_i+\cdots+p_j$ ((2k,2k-1) are always red). In at most $\frac{n-1}{2}$ 2x2 squares I can have two red points namely $(2k,2l-1)$ and $(2k-1,2l)$ because this requires $p_{2k-1}+p_{2l}=n$ Therefore the total number of red points is at most $\frac{n^2-1}{8}+\frac{n-1}{2}$, which includes bogus points $(2k,2k-1)$ for $k\le \frac{n-1}{2}$, so there are at most $\frac{n^2-1}{8}$ valid pairs. Now the element n contributes at most $\frac{n+1}{2}$. Summing yields the result.
05.07.2022 21:18
The answer is $\frac{(n+1)(n+3)}{8}$, obtained by taking $1,n-1,2,n-2,\ldots ,\frac{n-1}{2},\frac{n+1}{2},n$. For convenience, write $p_i +p_{i+1} +...+p_j=f(i,j)$. First, remove $n$ from the permutation; it's easy to see that it contributes at most $\frac{n+1}{2}$ to $S$, so we will add that amount back later on. The following is the key claim: for at most $\frac{n-1}{2}$ pairs $(a,b)$ with $1\le a<b\le \frac{n-1}{2}$ can we have two of $f(2a,2b),f(2a,2b-1),f(2a-1,2b),f(2a-1,2b-1)$ be multiples of $p$. Proof: Note that $f(2a,2b)-f(2a,2b-1)=p_{2b},f(2a,2b)-f(2a-1,2b)=-p_{2a-1},f(2a,2b)-f(2a-1,2b-1)=p_{2b}-p_{2a-1}$. For the assertion to hold true, we need $p_{2a}\equiv p_{2b-1}$ mod $n$. Call these pairs "C-pairs". Now, each pair $(2k,2k+1)$ can contribute to $S$ iff $a_{2k}+a_{2k+1}\equiv 0\pmod{n}$. Hence, the sum of the contribution of C-pairs and the contribution of pairs of the form $(2k,2k+1)$ is at most $\frac{n-1}{2}$. Counting the $\binom{\frac{n-1}{2}}{2}$ original $(a,b)$ pairs, we have an upper bound of $\binom{\frac{n-1}{2}}{2}+\frac{n-1}{2}+\frac{n+1}{2}=\frac{(n+1)(n+3)}{8}$ as desired.