= $y && ($x - $y) >= $z) { $ans += $y; $ans += $z; }elseif ($x < $y && ($y - $x) >= $z) { $ans += $x; $ans += $z; }elseif ($x >= $y && ($x - $y) < $z) { $ans += $y; $ans += floor(($x -$y + $z)/2); }else { $ans += $x; $ans += floor(($y - $x + $z)/2); } echo $ans;