Prove that $f$ is integrable if and only if $\sum^\infty_{n=1} \mu(\{x \in X : f(x) \ge n\}) < \infty$
Convince yourself that $$f(x)-1\leq \sum_{n=1}^\infty {\bf 1}_{(f\geq n)}(x)\leq f(x)$$ for all $x\in X$, then integrate with respect to $\mu$.
Define $A_k=\{x:f(x)\geq k\}$ (as you had done so) and $B_k=\{x:f(x)\in[k,k+1)\}$. The $B_k$ are pair-wise disjoint. We have $\displaystyle X=\bigcup_{k=0}^\infty B_k$. Also note that $\displaystyle A_n=\bigcup_{k=n}^\infty B_k$. This gives us $\displaystyle \mu(X)=\sum_{k=0}^\infty \mu(B_k)$ and $\displaystyle \mu(A_n)=\sum_{k=n}^\infty \mu(B_k)$.
Assume non-negative $f:X\rightarrow \Bbb R$ is integrable, then
$$\infty>\int_X f d\mu \geq \sum_{k=1}^\infty k\mu(B_k)= \sum_{k=1}^\infty \mu(A_k). $$
Writing out $\mu(B_k)$ each $k$ times in a list/grid and rearranging the sum appropriately shows the last equality. This gives one direction.
For the other direction, assume $\displaystyle \sum_{k=1}^\infty \mu(A_k)<\infty$.
Since $f$ is measurable and bounded on each $B_k$, it is integrable on each $B_k$ (prove this), and we have
$$ \begin{aligned} \int_{X} f d\mu&=\lim_{N\rightarrow\infty}\sum_{k=0}^N \int_{B_k} f d\mu\\ &\leq \lim_{N\rightarrow\infty}\sum_{k=0}^N (k+1)\mu(B_k) \\ &=\mu(X)+\mu(A_1)+\mu(A_2)+\cdots<\infty \end{aligned} $$
Again, writing out $\mu(B_k)$ each $k+1$ times in a list/grid and rearranging the sum appropriately shows the last equality.