\(P=\left|x-1\right|+\left|x-2017\right|+\left|x-2018\right|\\ \Leftrightarrow P=\left|x-1\right|+\left|2018-x\right|+\left|x-2017\right|\\ \Leftrightarrow P=2017+\left|x-2017\right|\\ \Leftrightarrow P\ge2017\)
+Dấu ''='' xảy ra khi
\(\Leftrightarrow\left\{{}\begin{matrix}x\ge1\\x\le2018\\x=2017\end{matrix}\right.\)
\(\Leftrightarrow x=2017\)
+Vậy \(P_{min}=2017\) khi \(x=2017\)