← All problemsSign in

Bus full of passengers

CodeChefRating 1553Open on judge ↗

There is an **empty bus** with $M$ seats and a total of $N$ people, numbered from $1$ to $N$. Everyone is currently outside the bus. You are given a sequence of $Q$ events of the following form. - $+\ i$ : It denotes that the person $i$ enters the bus. - $-\ i$ : It denotes that the person $i$ leaves the bus. It is guaranteed in the input that each person from $1$ to $N$ enters *at most* onc

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start