TITLE: Choosing half of prefix and suffix
QUESTION [7 upvotes]: Consider two lists: $(1,2,\dots,n)$ and $(a_1,a_2,\dots,a_n)$, where the second list is a permutation of the first. Does there exist a constant $c$ such that for any $n$ and for any second list, we can choose a subset $A\subseteq\{1,2,\dots,n\}$ of size at most $n/2+c$ so that for any prefix and suffix of either list of any length $k\in[1,n]$, at least $k/2$ of those elements are in $A$?

The $n/2$ part is necessary: even if we just have the list $(1,2,\dots,n)$ and require the condition on the prefix, when taking $k=n$ we already need to include at least $n/2$ elements. If we only want the prefixes and suffixes of the first list, we can choose $A=\{1,3,5,\dots\}$ along with $n$ (if not already included), which comes to at most $n/2+1$ elements.

REPLY [3 votes]: This problem can be reformulated as "Given a permutation $\sigma$ of $\{1,\dots,n\}$, is it always possible to choose $a_j=\pm 1$ such that all partial sums $\sum_{j=1}^k a_j$ and $\sum_{j=1}^k a_{\sigma(j)}$ are bounded by some constant $C$". The answer is "Yes". Consider the graph in which the vertices are $1,\dots,n$ and edges are $1-2,3-4,5-6,\dots$ (white) and $\sigma(1)-\sigma(2), \sigma(3)-\sigma(4),\dots$ (yellow). If we manage to choose the signs so that every edge connects two vertices of different signs, we are done. However, the only chance to get a cycle in this graph is to alternate white and yellow edges, so all cycles are even, making our choice possible.
A more interesting question is what happens if instead of one, we have 5 permutations. I suspect the answer is still positive but, of course, this simple approach has to be modified to cover that case.