The following table shows the number of employees and their median age in eight companies located in a district.
| Company | Number of employees | Median age |
|---|---|---|
| A | 32 | 24 |
| B | 28 | 30 |
| C | 43 | 39 |
| D | 39 | 45 |
| E | 35 | 49 |
| F | 29 | 54 |
| G | 23 | 59 |
| H | 16 | 63 |
It is known that the age of all employees are integers. It is known that the age of every employee in A is strictly less than the age of every employee in B, the age of every employee in B is strictly less than the age of every employee in C, ..., the age of every employee in G is strictly less than the age of every employee in H.
The highest possible age of an employee of company A is:
The Setup: Think of these companies as sorted C++ arrays. We need to maximize the final element of array A without throwing a logic error when it's compared to the very first element of array B. It's a strict inequality check, so we need to min-max the data to push Company A's ceiling as high as possible.
Step 1: Decode the median mechanics for Company B. Company B has employees (an even number). The median age () is the average of the two middle elements. If we use standard 1-based math indexing, that's the th and th employees:
Step 2: Find the lowest possible starting age for Company B. To give array A the most room to scale up, we must push B's values as low as the rules allow. We can initialize the first elements in B to exactly without breaking the median requirement: .
Thus, the absolute minimum age for the youngest employee in B is .
Step 3: Lock in Company A's max age. The constraint dictates that *every* employee in A must be strictly younger than *every* employee in B. In code terms, . Since ages are strictly typed integers, if , the absolute maximum allowed for is .
Step 4: Verify this doesn't break Company A's own median constraint. Company A has employees with a median of . This requires the average of and to be . We can easily assign and , which leaves plenty of capacity for elements through to cap out at . The backend logic runs with zero lag, and the max age holds up perfectly.
Final Answer: 29