For both a<b , maximum possible difference is abs((a)-(b-a)). See for maximum possible difference one tastiness must be maximum and another tastiness must be minimum. Understand that there are 2 dishes which have tastiness t1 and t2 and both 0<t1,t2<=a.
and 0<(t1+t2)<=n, now when a<b, means sum is more than individual maximum value a, it means the maximum tastiness of a dish is a and minimum is (b-a) , so the maximum difference is
abs(a-(b-a)). similarly in the case when a=5 and b=6 , so maximum tastiness of a dish is 5 and minimum tastiness is (6-5)=1 , so the difference is 5-1=4