An elevator with a capacity of N people in a building with E floors works in a pretty unusual way.
The elevator starts at the first floor and it goes to the top floor before returning to the first floor.
It stops at every floor that is a destination of a person in the elevator.
It also stops when 1) there is someone at the current floor who wants to travel in the same direction as the elevator is currently traveling and 2) there is still room in the elevator.
At least how many round trips to the top and back are necessary to carry every person to their destination?
I assume that some kind of Greedy algorithm can give a good algorithm to solve this problem, but I still have no idea how to write a pseudocode for it.