Let x be the number of boys, then the number of girls will be (60−x).
The mean weight of boys is 50 kg, then the total weight of boys will be, 50x.
The mean weight of girls is 30 kg, then the total weight of girls will be 30(60−x)=1800−30x.
The mean weight of 60 students is 40 kg, so
weightofgirls+weightofboystotalno.ofstudents=40
1800−30x+50x60=40
x=60020
x=30
So, the number of boys is 30 and the number of girls is (60−30)=30.