Can anyone explain the intuition of the problem Elevator Riding(CSES Problem)?

Problem link CSES - Elevator Rides

Have a look here