TITLE: Largest subset with no arithmetic progresssions
QUESTION [6 upvotes]: Let $A=\{x_1,x_2,\cdots,x_n\}$ be a set of $n$ distinct real numbers. Show that there exists a set $B\subset A$ such that $$|B|\geq\lfloor\sqrt{2n}+\frac12\rfloor$$ and no $3$ distinct elements of $B$ constitute an arithmetic progression.

I have no idea how to approach this problem, with its strange-looking formula. I've already posted it on AoPS but no reply.

REPLY [6 votes]: This is accurate estimate!
Perform a greedy algorithm. At start $B= \emptyset$. Now repeat: Take arbitrary element $a\in A$, delete it in $A$ and

if it doesn't make AP in $B$ then put it in $B$  .
if $a$ make AP with some $x,y\in B$ and

if $a\ne {x+y\over 2}$ (it is not in the middle of $x,y$) then we refute it,
if $a= {x+y\over 2}$ (it is in the middle of $x,y$) then we replace $x$ or $y$ with $a$ in $B$.



We finish when $A = \emptyset$. Now we do double counting between unordered pairs in $B$ and $B^C$.
Pair $\{x,y\}\subset B$ connect with $z\in B^C$ iff $x,y,z$ are in AP.
Every unordered pair in $B$ is connected with at most $1$ (and not $3$) elements in $B^C$. So, if $|B|=m$,  then we have:
$$\binom{m}{2}\geq n-m\iff m\geq\frac{\sqrt{8n+1}+1}{2}$$