Ta có: \(\left\{{}\begin{matrix}\left(x+5\right)^2\ge0\forall x\\\left|x-y+1\right|\ge0\forall x,y\end{matrix}\right.\)
\(\Rightarrow\left(x+5\right)^2+\left|x-y+1\right|\ge0\forall x,y\)
\(\Rightarrow-\left[\left(x+5\right)^2+\left|x-y+1\right|\right]\le0\forall x,y\)
\(\Rightarrow-\left(x+5\right)^2-\left|x-y+1\right|\le0\forall x,y\)
\(\Rightarrow P=-\left(x+5\right)^2-\left|x-y+1\right|+2018\le2018\forall x,y\)
Dấu \("="\) xảy ra khi: \(\left\{{}\begin{matrix}x+5=0\\x-y+1=0\end{matrix}\right.\Rightarrow\left\{{}\begin{matrix}x=-5\\y=x+1\end{matrix}\right.\)
\(\Rightarrow\left\{{}\begin{matrix}x=-5\\y=-4\end{matrix}\right.\)
Vậy \(Max_P=2018\) khi \(x=-5;y=-4\).
$Toru$