Suppose i have functions $f(x)=min(c_1,max(b_1,x+a_1))$ and $g(x)=min(c_2,max(b_2,x+a_2))$ , how to prove that $g(f(x))=min(c,max(b,x+a))$ . Here except $x$ all other values are constants.
Motivations of the problem : I was reading editorial of some problem here but i was not able to understand how 3rd step came from 2nd in the proof.