5. In the Cartesian coordinate system $x O y$, it is known that points $A(3,3)$, $B(-2,1)$, and $C(1,-2)$. If $T$ represents the set of all points inside and on the sides (including vertices) of $\triangle A B C$, then the range of the bivariate function $f(x, y)=\max \{2 x+y$, $\left.x^{2}-y\right\}($ where $(x, y) \in T)$ is
5. $\left[\frac{129-12 \sqrt{139}}{25}, 9\right]$.

Divide $T$ into two parts and discuss them separately.
(1) When $2 x+y \geqslant x^{2}-y$, i.e., $y \geqslant \frac{x^{2}}{2}-x$, then $f(x, y)=2 x+y$.
Let the parabola $y=\frac{x^{2}}{2}-x$ intersect sides $A B$ and $A C$ at points $D$ and $E$, respectively. Point $(x, y)$ moves on the curved triangle $A \overparen{D E}$ (where $\overparen{D E}$ is a segment of the parabola), as shown in Figure 4.

It is easy to see that at point $A(3,3)$, $(2 x+y)_{\max }=9$.
From the system of equations
$$
\left\{\begin{array}{l}
y=\frac{x^{2}}{2}-x \\
y=\frac{2}{5} x+\frac{9}{5}
\end{array}\right.
$$

eliminating $y$ and rearranging gives
$5 x^{2}-14 x-18=0$.
1214
Taking the smaller root $x=\frac{7-\sqrt{139}}{5}$, the corresponding $y=\frac{59-2 \sqrt{139}}{25}$.
Thus, $D\left(\frac{7-\sqrt{139}}{5}, \frac{59-2 \sqrt{139}}{25}\right)$.
Similarly, $E\left(\frac{7-\sqrt{13}}{2}, \frac{17-5 \sqrt{13}}{4}\right)$.
Next, consider whether the line $y=-2 x+k_{1}$ is tangent to the parabola arc $\overparen{D E}$ within $T$. For this, from the system of equations $\left\{\begin{array}{l}y=\frac{x^{2}}{2}-x, \\ y=-2 x+k_{1}\end{array}\right.$, eliminating $y$ gives $x^{2}+2 x-2 k_{1}=0$. Setting its discriminant $\Delta=2^{2}+8 k_{1}=0$, we get $k_{1}=-\frac{1}{2}$. At this point, $x=-1, y=\frac{3}{2}$, and this tangent point $\left(-1, \frac{3}{2}\right)$ is outside $T$ (above line segment $A B$), so the line $y=-2 x+k_{1}$ does not intersect the parabola arc $\overparen{D E}$ within $T$.

From the above, the maximum value of $k_{1}=2 x+y$ on the curved triangle $A \overparen{D E}$ is 9, and the minimum value is $2 \times \frac{7-\sqrt{139}}{5}+\frac{59-2 \sqrt{139}}{25}=\frac{129-12 \sqrt{139}}{25}$.
(2) When $2 x+y \leqslant x^{2}-y$, i.e., $y \leqslant \frac{x^{2}}{2}-x$, then $f(x, y)=x^{2}-y$, and point $(x, y)$ moves on the curved quadrilateral $B C \overparen{E D}$ (where $\overparen{E D}$ is a segment of the parabola), as shown in Figure 4.

Note that the parabola $y=x^{2}-k_{2}$ opens upwards. When $y=x^{2}-k_{2}$ passes through point $D\left(\frac{7-\sqrt{139}}{5}, \frac{59-2 \sqrt{139}}{25}\right)$, $-k_{2}$ takes its maximum value, and thus, $k_{2}$ takes its minimum value $\left(\frac{7-\sqrt{139}}{5}\right)^{2}-\frac{59-2 \sqrt{139}}{25}=\frac{129-12 \sqrt{139}}{25}$;

When $y=x^{2}-k_{2}$ passes through one of points $B$, $C$, or $E$, $-k_{2}$ takes its minimum value, i.e., $k_{2}$ takes its maximum value $\max \left\{1^{2}-(-2),(-2)^{2}-1\right.$, $\left.\left(\frac{7-\sqrt{13}}{2}\right)^{2}-\frac{17-5 \sqrt{13}}{4}\right\}=\frac{45-9 \sqrt{13}}{4}$.