Editorial for Faulty Check-in
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Hints
Hint 1
Show Hint
At any point in time, Jackson only has 3 options: Check in the first queue student, check in the second queue student, or move the first queue student to the front of the second queue.Hint 2
Show Hint
Because of the first hint, and because we always know the next student Jackson needs to check in, there is always really only a single choice for Jackson - what should Jackson do in what scenario?Hint 3
Answer to Previous Hint
If Jackson sees the next student ID at the front of either queue, he should check them in, always.Otherwise, he can only take the student in the first queue, and move them to the front of the second queue.
Comments