Given two $n \times n$ symmetric positive definite matrices $A$ and $B$, I am interested in solving the following optimization problem over $n \times n$ unitary matrices $R$:
$$
\mathrm{arg}\max\_R \,\mathrm{trace}(RAR^TB)~~~\text{s.t.}~~~RR^T = I\_n~.
$$
More generally, given two sets of $m$ positive definite matrices $\{A\_i\}\_{i=1}^m$ and $\{B\_i\}\_{i=1}^m$ I would like to solve:
$$
\mathrm{arg}\max\_R \,\sum\_i\mathrm{trace}(RA\_iR^TB\_i)~~~\text{s.t.}~~~RR^T = I\_n~.
$$

If I recall correctly, I have seen the following inequality
$$
\mathrm{trace}(R\,\mathrm{diag}({\bf c})\,R^T\,\mathrm{diag}({\bf d})) \le {\bf c}^T{\bf d}
$$
for positive vectors ${\bf c}$ and ${\bf d}$. If this inequality is correct, then $R=I\_n$ provides the optimal solution for diagonal matrices and using spectral decomposition of non-diagonal $A$ and $B$ we can solve the problem in the case of $m = 1$. Can somebody please show me how to prove this inequality? More importantly, Is there a way to solve the problem in the more general case of $m > 1$?