Concept:
For an ideal gas, we use the equation $PV = nRT$. Since the mass (and $n$) is the same in both parts, we use the relationship:
\[ \frac{P_1 V_1}{T_1} = \frac{P_2 V_2}{T_2} \]
When the piston shifts and stabilizes, the pressure on both sides must be equal ($P_{final}$).
Step 1: Analyze the part that is NOT heated.
Let Part A be heated and Part B remain at 300 K.
Initially: $V_B = 45A$ (where $A$ is cross-section), $P_B = 1$ atm, $T_B = 300$ K.
Finally: The piston moves 5 cm away from Part A into Part B.
$V_B' = (45 - 5)A = 40A$. $T_B$ remains 300 K.
\[ P_{final} = \frac{P_B V_B}{V_B'} = \frac{1 \times 45A}{40A} = 1.125 \text{ atm} \]
Step 2: Analyze the part that IS heated (Part A).
Initially: $V_A = 45A, P_A = 1 \text{ atm}, T_A = 300$ K.
Finally: $V_A' = (45 + 5)A = 50A, P_{final} = 1.125 \text{ atm}, T_{final} = ?$
\[ \frac{P_A V_A}{T_A} = \frac{P_{final} V_A'}{T_{final}} \implies \frac{1 \times 45}{300} = \frac{1.125 \times 50}{T_{final}} \]
\[ T_{final} = \frac{1.125 \times 50 \times 300}{45} = \frac{56.25 \times 300}{45} = 1.25 \times 300 = 375 \text{ K} \]