I did this a little differently than the other solution.
I used the Highway level where I believe the requirement for S is 4.2 million. I came in just under 4.5m and missed eating a ghost train at the very end.
I opted to eat every pellet to get the bomb on each level. At the end of the run, I had 6 lives and 20 bombs that gave me a bonus of 435,000.
The keys to success are not dying, getting all pellets (bombs), getting all 1-ups (which appear near the objective spawn at score increments of 1m), being fast and accurate with your general pathing, and eating the ghost trains quickly to not lose time. On stage 16 you should probably just get the power pellet asap and eat trains until time runs out as this strat doesn't really leave time to go much further.