It's the same with software engineering, being able to reason about possible bugs just by looking at some code comes from training/experience.
Now, on this problem, some train of thought is like this:
100 people join of their own free will, no limit other then value-from-waiting > value-from-not-waiting.
If extra coffeee then valueFromWaiting - valueFromNot = 75c. Cost per person 0.25c
But... this means more people queue up ontil valueFromWaiting - valueFromNot = 0. (basic economy knowlege being tested)
So what's the grand cost and how come it's 100$?, well, I could argue that
Sum(1$ - valueForPerson(i)) from 1 to NewEquilibriumPersonCount == Sum(1$) from 1 to OldPersonCount.
Because NewEquilibriumPersonCount is function of ValuePerPerson. (can probably deduce how given some time or some reading would help)
Grasping this sort of logic is when GPT will be scary.
It's a mind-reading game of which assumptions the professor/interviewer wants to keep solid which ones are open to change.
When the government gives free coffee to the people in line now the perceived value is the value of the raspberries at the controlled price plus the $ .75 of the coffee, making it worth to queue more - until the queue gets to the length at which the waiting time exceeds the value of the added coffee.