Say I have P number of political parties in an election that I'm trying to rig. My boss has decided what number of percentage of the votes it is best that each party should get. N number of votes have already been cast and it has already been publicly known what party they cast their votes. I have X votes remaining and I need to calculate how to cast them in an as "fair" way as possible. That is, if a party is supposed to get 25% of the votes and I can't make that happen with my remaining votes, my cheat votes should be distributed in a way that makes their share as close as possible to that number. But it is better if two parties suffer a 3% point deviation from their target rather than one suffering 6% point and the other 0%.
Also, to make the problem more interesting (if it is to easy) the acceptable deviation should be proportional to the size of the party target. It is better if a party that should have gotten 45% gets 40% rather than one that should have gotten 5% gets 1% because its absolute size is smaller so the deviation matters much more.