I'm not sure how elegant this is, but it seems to get the job done.
Using your posted workbook...
• This ARRAY FORMULA, completed by holding down CTRL and SHIFT when you press ENTER (instead of just pressing ENTER)
determines which column is under-represented
Copy H3 and paste into H4:H36
• This regular formula begins the allocations
Copy that formula across and down through G36.
Using your posted data, these will be the end results for C37:G37
Is that something you can work with?
Copy H4 and Paste into
Bookmarks