I read the editorial and i have understood the solution . Two key points in the solution are :
1.sorting on the basis of beauty.
2.observing that $$$max(c_i,a_j-a_i)=c_i+max(0,a_j-a_i-c_i)$$$.
After that finding solution is trivial.
I have personally solved problems with similar difficulties but i always wonder how the people who solved this in contest reached to such points. I can come up with such observations but it always take lot of time .
Can people who solved this during the contest share the thought process.