Let $X$ be a set and $\mathcal S$ be a $\sigma$-algebra on $X$. Let $\mu$ be a measure on $(X,\mathcal S)$, that is a map from $\mathcal S$ to $[0,\infty]$ such that $\mu(\varnothing)=0$ and $\mu\left(\bigcup_{n\in\omega} A_n\right)=\sum_{n\in\omega}\mu(A_n)$ for any countable family $\{A_n:n\in\omega\}$ of pairwise disjoints members of $\mathcal S$.
Proposition. Let $f:X\to [0,\infty)$ and $f^*:(0,\infty)\to [0,\infty)$ be functions such that
$f^{*}(t) = \mu(\{x |f(x) > t\})$ for each $t>0$. Let $I=\int_{0}^{\infty}f^{*}(t)dt$ and $S$ be the supremum of all sums of the form $\sum_{i=1}^n t_i\mu(A_i)$, where $A_1,\dots, A_n\in \mathcal S$ are pairwise disjoint and for each $i\le n$ we have $\mu(A_i)<\infty$ and $f(x)\ge t_i>0$ for each $x\in A_i$. Then $I=S$.
Proof. The function $f^{*}$ is nonnegative and nondecreasing, so the improper Riemann integral $I=\int_{0}^{\infty}f^{*}(t)dt$ exists (but can be infinite).
Suppose first that $S<\infty$.
Let $\varepsilon>0$ be any number. Then there exist natural $n$, pairwise disjoint sets
$A_1,\dots, A_n\in \mathcal S$, and positive numbers $t_1<\cdots<t_n$ such that
for each natural $i\le n$ we have $\mu(A_i)<\infty$ and $f(x)\ge t_i>0$ for each $x\in A_i$,
and $\sum_{i=1}^n t_i\mu(A_i)>S-\varepsilon$. For the convenience put $t_0=0$ and $t_{n+1}=\infty$.
For each natural $i$ put $B_i=\bigcup_{j=i}^n A_j$. Then for each natural $i$ and each $t<t_i$ we have
$f(B_i)\subset (t,\infty)$, so $f^*(t)\ge \mu(B_i)$. Then we have $$S-\varepsilon<\sum_{i=1}^n t_i\mu(A_i)=\sum_{i=1}^n (t_i-t_{i-1})\sum_{j=i}^n\mu(A_j)=\sum_{i=1}^n (t_i-t_{i-1})\mu(B_i)=$$
$$\sum_{i=1}^n \int_{t_{i-1}}^{t_i} \mu(B_i)dt\le
\sum_{i=1}^n \int_{t_{i-1}}^{t_i} f^*(t) dt =
\int_{0}^{t_n} f^*(t) dt\le I.$$
It follows $S\le I$. For the case $S=\infty$ we can show that $S\le I$ verbatim to the above, but the only changes of $S-\varepsilon$ to any $N>0$.
Suppose first that $I<\infty$.
Let $\varepsilon>0$ be any number. Then there exist positive numbers $T<T'$ such that
$\int_{T}^{T'}f^*(t) dt>I-\varepsilon$. By the definition of the definite integral, there exist a natural number $n$ and positive numbers $T=t_0<\cdots<t_n=T'$ such that $$\int_{T}^{T'} f^*(t) dt-\varepsilon<\sum_{i=1}^n (t_i-t_{i-1})f^*(t_i).$$
Put $B_0=\varnothing$ and for each natural $i\le n$ put $B_i=f^{-1}(t_i,\infty)$.
Then $B_i\in\mathcal S$ and $\mu(B_i)=f^*(t_i)<\infty$. Next, put $A_n=B_n$ and for each natural $i\le n-1$ put $A_i=B_i\setminus B_{i+1}$. Then $A_i\in\mathcal S$,
$\mu(A_i)\le\mu(B_i)<\infty$, $f(x)>t_i$ for each $x\in A_i$, and $B_i=\bigcup_{j=i}^n A_j$. Now we have
$$\sum_{i=1}^n (t_i-t_{i-1})f^*(t_i)=\sum_{i=1}^n (t_i-t_{i-1})\mu(B_i)=$$ $$
\sum_{i=1}^n (t_i-t_{i-1})\sum_{j=i}^n\mu(A_j)=\sum_{i=1}^n (t_i-t_0)\mu(A_i)\le S-\varepsilon.$$
It follows $I\le S$. For the case $I=\infty$ we can show that $I\le S$ verbatim to the above, but the only changes of $I-\varepsilon$ to any $N>0$.
$\square$