By raising prices on the high demand stuff, you send a signal to the people that can get by with alternative stuff that now is a good time to do so.
So, like, highly hypothetically, if I couldn't find a calculator for a good price, I'm in a good seat to whip out my slide rule. This gives me an edge over the people who have to pay high prices for calculators, and simultaneously smooths out demand. What's good for me is also good for the people who really need calculators.
Optimally distributing fewer goods isn't a solution to the problem. The problem is a shortage.
That number isn't a constant, it is a function of supply and demand. Therefore there is no such thing as a chip shortage. We'd maybe like prices to be higher or lower depending on our perspective.
> What happens when the good in question is food?
If there are 10 mouths and 9 meals then there is a food shortage. But that is a biological observation, not an economic one.
It does take some time for prices to adjust, and if the supply and/or demand curves shift very quickly, there absolutely can be a temporary shortage. I think that's what we're going through now.
It isn't like COVID is a surprise any more, it has been with us for nearly 2 years.
Prices go up on the food most people prefer to eat, first. People who cannot afford the foods they're accustomed to eating will switch to lower-priced foods they would never have considered otherwise.
That's largely how tomatoes, potatoes, and more came into use... Desperate, hungry peasants.
When food suppliers see the increase in price, they will work hard to squeeze more yield out of their existing supplies, and as soon as possible will invest in producing more (typically for next year). Others who are capable of producing food, but normally produce something else due to economics, will see the equation change in favor of food and switch their output.
Famines are not caused or encouraged by supply/demand economics. It is vastly more common for communist governments to cause them.