Skip to main content

Practice · 4 of 6

Final 4: The Deadlines

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** A single barber has n clients; client i needs t[i] minutes and must be finished by minute d[i] (clients start at minute 0, one at a time, no gaps). Client i is *late* by max(0, finish − d[i]). Schedule to minimize the maximum lateness; print it. **Constraints:** 1 ≤ n ≤ 200000; 1 ≤ t[i] ≤ 10^3; 1 ≤ d[i] ≤ 2·10^4. **Input:** line 1: n; then n lines: t, d. **Output:** one integer.

Back to lesson: Practice: The Final Pack