Solution (source code)

= Solution

For $u\geq0$, let $\mathcal C_u$ be the collection of interval components of the <superlevel set> $\{r:g(r)\geq u\}$. Two times $s,t$ lie in the same member of $\mathcal C_u$ exactly when $u\leq m_g(s,t)$. Therefore
$$
m_g(s,t)=\int_0^\infty\sum_{C\in\mathcal C_u}
\mathbf1_{\{s\in C\}}\mathbf1_{\{t\in C\}}\,du.
$$
For arbitrary real $\lambda_1,\ldots,\lambda_n$, the <Tonelli theorem> now gives
$$
\sum_{i,j}\lambda_i\lambda_jm_g(s_i,s_j)
=\int_0^\infty\sum_{C\in\mathcal C_u}
\left(\sum_{i:s_i\in C}\lambda_i\right)^2du\geq0.
$$
Thus $(m_g(s_i,s_j))_{i,j}$ is a <positive semidefinite matrix>.