Best-of-Majority: Minimax-Optimal Strategy for Pass@$k$ Inference Scaling