Serving in Order
Challenge on lesson: Checkpoint — STL
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** A counter serves customers. Process q events of three kinds:
1 x — customer with ticket x joins the queue;
2 — serve (remove) the customer at the front;
3 — print the smallest ticket currently waiting, or -1 if nobody waits.
**Input:** Line 1: q (1 <= q <= 2*10^5). Next q lines: an event as described
(1 <= x <= 10^9).
**Output:** One line per event of kind 3.
**Example:** 6 / 1 5 / 1 3 / 3 / 2 / 3 / 1 4 -> 3 / 5.
Press Submit to check your solution.
Back to lesson: Checkpoint — STL