I would imagine the PM tells the CE what she wants to prioritise, then instructs him to find a way to do it. He runs off and tells all his plebs to do the proper maths, they come back to him with a couple of ideas then he passes that up the line to the PM, who makes the final decision.
Politics is too political to leave it purely down to people who actually know what they're doing. They'd rather look good to the public than do what's right, hence the reason the NHS hasn't been torn apart and made into something that actually works.