Zend certified PHP/Magento developer

how to distribute clients with due amounts over agents based on amounts on excel

i’m not sure how to put it right but bear with me.
let’s say i own a company and i have like 5 clients who owe me money.
so, i hired 3 agent to try retrieve the money for me for a commission of 20% of the retrieved money.
i want to distribute these clients over the 5 agents evenly or semi-evenly based on the amount of money owed.

Client 1 owes me 1000

Client 2 owes me 2000

Client 3 owes me 3000

Client 4 owes me 2000

Client 5 owes me 4000


Agent 1 will take Client 1, 3 (Total amount of money is 4k)

Agent 2 will take Client 2, 4 (Total amount of money is 4k)

Agent 3 will take Client 5 (Total amount of money is 4k)

but let’s say i have like 20k clients with due amounts of whole and rational amounts,
i know there’s no way to distribute it evenly over agents but we can set a limit for the money given to each agent.
like if the total amount of money is 353,464.42 each agent should take around 117,821,47 give or take.

how to come up with a formula to do this?