#C8844. Minimize Guest Variation
Minimize Guest Variation
Minimize Guest Variation
You are given n sections where each section i has a seating capacity a_i and a number of amenities b_i. The total seating capacity is \(T = \sum_{i=1}^{n} a_i\). In order to balance the guest distribution, you need to determine the smallest integer \(M\) such that if each section is filled with \(\min(a_i, M)\) guests, the total number of guests is at least \(T\).
Formally, find the minimum integer \(M\) such that:
[ \sum_{i=1}^n \min(a_i, M) \ge T ]
This ensures that the variation between the fullest and the least filled sections is minimized. Although the problem statement mentions maximizing the access to amenities, the number of amenities provided in each section (bi) does not affect the calculation of \(M\).
Note: All formulas are in \(\LaTeX\) format.
inputFormat
The input is given in three lines:
- The first line contains an integer n, the number of sections.
- The second line contains n space-separated integers representing the seating capacities ai of each section.
- The third line contains n space-separated integers representing the number of amenities bi in each section.
outputFormat
Output a single integer \(M\), the minimized maximum number of guests any section can accommodate under the criteria described above.
## sample4
10 30 20 10
2 4 3 1
18
</p>