Initially, there are charge $q=CV$ and energy $CV^2/2$ stored on the left capacitor. When the circuit is closed, the same current flows through both resistors and the ratio of the heat generated in each of them is
$$\frac{Q_1}{Q_2}=\frac{R_1}{R_2}.$$
When the circuit reaches steady state and there is no current, there are charge $q/2$ and energy $(q/2)^2/(2C)=CV^2/8$ stored on each capacitor. Thus, the total heat generated is