Here's a different approach. (Nice solution BTW biffboy).

For the larger mass let down be the positive direction and suppose that the tension in the string is

Then, (F=ma),

for the larger mass

and for the mass on the slope,

Adding, (and taking

to be

so

Now use one of the equations of motion for a body moving with constant acceleration

and we have, when the large mass comes to rest,

so

(Since down is the positive direction, the negative sign reflects the fact that the larger mass has moved upwards before coming (momentarily) to rest.)

The gain in energy of the larger mass will be its gain in PE minus its loss in KE

The tension in the string we can get from (1) or (2),

From (1),