I will let someone else deal with the particulars but I say about these theoretical situations what Aristotle says in the Nichomachean Ethics, that what a good man would do is the good thing. But you don't know until the situation what you would do. Suppose among the larger groups was your family. then your higher responsibility to the family enters in. Suppose among the larger group were several murderers.
My goal would be to save all of them. You define that as not possible but that is you and not the situation.
maybe you jumping in front of the train would at least make the conductor sooner slam on the brakes and minimize the damage.