Without loss of generality, let the elements of A in increasing order be x0,x1,…,x2024. We first compute P(A). For each xm, we count how many odd-sized subsets have xm as their median. A subset B of odd size has xm as its median if and only if
∣B∩{x0,…,xm−1}∣=∣B∩{xm+1,…,x2024}∣.
If this common value is d, the number of such subsets B is (dm)(d2024−m). Thus, the total number of such B is
d∑(dm)(d2024−m)=d∑(m−dm)(d2024−m)=(m2024),
where the last equality follows from Vandermonde's identity. Therefore,
P=m=0∑2024(m2024)xm.
Next, we compute Q(A). For each xm, we count how many even-sized subsets have xm as one of their two middle elements. The number of such subsets is
d∑((d+1m)(d2024−m)+(dm)(d+12024−m))=d∑(m−d−1m)(d2024−m)+d∑(m−dm)(d+12024−m)=(m−12024)+(m+12024).
Thus,
Q=m=0∑202421((m−12024)+(m+12024))xm.
---
Since multiplying all elements of A by a positive constant does not change the problem, we may assume x2024=1. Let yi=xi−xi−1 for i=0,1,…,2024 (with x−1=0). Then P−Q can be expressed as a linear form in y0,y1,…,y2024, where the yi are positive and sum to 1. The minimal c is therefore equal to the maximum coefficient of the yi.
The coefficient of xm in P−Q is (m2024)−21((m−12024)+(m+12024)). Thus, the coefficient of yi is
m=i∑2024((m2024)−21((m−12024)+(m+12024)))=m=i∑2024(m2024)−21(m=i−1∑2024(m2024)+m=i+1∑2024(m2024)−1)=2(i2024)−(i−12024)+1.
We now find the maximum of (i2024)−(i−12024). For i≥1013, (i2024)−(i−12024)≤0, so the maximum must occur for 0≤i≤1012. Let di=(i2024)−(i−12024). Then
di+1−di=(i+12024)+(i−12024)−2(i2024)=(i2024)(i+12025−i+2025−ii−2)=(i2024)((i+1)(2025−i)2025×2026−4).
For 0≤i≤1010, (i+1)(2025−i) increases with i. Since 991×10352025×2026<4<990×10362025×2026, we have di+1>di when i≤989 and di+1<di when i≥990. Thus, the maximum of di is achieved at i=990. Therefore, the minimal c is
c=2(9902024)−(9892024)+1.