enC#, given what each guest is ready to pay, you have to compute the restaurant's gains for the day: at the beginning of the day the restaurant is emplty; a guest arrives, finds a seat, eats, pays and then leaves; there are only nbSeats seats avaiable, guests can only eat and pay when they can be seated; a quest which enters the restaurant and cannot find a seat waits in line until a seat is made available or until he/she gets bored and leaves; a guest may come several times during the day, in that case, he/she will pay at most once. implement public static int ComputeDayGains(int nbSeats, List<int> payingGuests, List<int> guestMovements) which returns the gains for the day: list payingGuests gives what guests are ready to pay, the list guestMovements gives in order the arrivals and departures of guests. the first time you see an id, it indicates an arrival, the secondes time you see the same id, it indic a departure. an arrival is always followed later in the day by a departure. the giest indexes are 0-based, all the integers in guestMovements are between 0 and number of guests - 1
Aucun commentaire:
Enregistrer un commentaire