Approach hintTry it first, then revealHide
Global room numbers run through the dormitories in order, so prefix sums of their sizes split the numbering into ranges. Find each letter's range with lower_bound, or with a moving pointer since letters are sorted. Use long long.