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.
we have
$$f(x)=min(c_1,max(b_1,x+a_1))$$ $$g(x)=min(c_2,max(b_2,x+a_2))$$
Then it's something like
$$g(f(x))=min(c_2,max(b_2,min(c_1,max(b_1,x+a_1))+a_2))$$
$$=min(min(max(c_1,b_2),c_2),max(max(min(b_1,c_1),b_2),x+a_1+a_2^*))$$