#P11523. Booth Allocation by Garlic Association
Booth Allocation by Garlic Association
Booth Allocation by Garlic Association
T University hosts a large "Club Recruitment Fair" in which clubs are allocated a limited number of booths along a line with H slots. Given T clubs with contributions ui (in submission order), the coordinator decides to allocate booths using the following process:
For each club, compute the sequence: \[ u_i, \frac{u_i}{2}, \frac{u_i}{2^2}, \cdots, \frac{u_i}{2^{H-1}}. \]
Then, across all T × H computed values, repeat the following until all H booths are allocated:
- Remove one occurrence of the current maximum value and assign a booth to its corresponding club.
- If there are multiple occurrences of the maximum value, apply these tie-breakers in order:
- If one or more clubs among the tied candidates have not yet received any booth, only consider those clubs.
- From the remaining clubs, choose the club with the largest original contribution \(u_i\).
- If there is still a tie, choose the club that submitted its application earlier (i.e. lower index).
Calculate and output how many booths each club receives.
inputFormat
The first line contains two integers T and H, where T is the number of clubs and H is the number of booths.
The second line contains T space-separated integers \(u_1, u_2, \ldots, u_T\) representing each club's contribution.
outputFormat
Output T integers separated by spaces, where the i-th integer is the number of booths allocated to the i-th club.
sample
3 5
118 100 80
2 2 1