We calculating the ratio for 12 months

A's contribution= 50000*12

since B left x months before the end of the year so his contribution=60000(12-x)

and same for C= 70000(12-x)

their ratios

50000*12:60000(12-x):70000(12-x)

=> 60 : 6(12-x) : 7(12-x)

Now given ratio is 20:18:21

so we divide by 3 in the ratio

=> 20 : 3(12-x) : 7(12-x)/3

on comparing the B's ratio with the given one we get

3(12-x)=18

x=3