Skip to main content

Practice · 4 of 5

Cafeteria Queue

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** n students queue; student i needs t[i] seconds to be served. The counter serves them in order. Print, for each student, the second they finish (student 1 finishes at t[1]; student i finishes when student i-1 did, plus t[i]). **Input:** Line 1: n (1 <= n <= 200000). Line 2: n integers (1 <= t[i] <= 1000). **Output:** One line: n finish times, space-separated (fits in 64 bits). **Example:** 3 / 2 5 1 -> 2 7 8.

Back to lesson: Practice: Mixed Mock Problems