Question: Please help to write two functions in C++ , the instruction as following. I will rate the answer :) THANKS!! Movie Theatre Shuffle You work

Please help to write two functions in C++ , the instruction as following. I will rate the answer :) THANKS!!

Please help to write two functions in C++ , the instruction as

following. I will rate the answer :) THANKS!! Movie Theatre Shuffle You

Movie Theatre Shuffle You work at a movie theatre, ushering people to their assigned seats. There are S seats, all in one row, and the seats are numbered 1 through S (starting from the left, in increasing order). There are S customers in line, each of whom has a unique seat they're assigned to Once seated, a customer will not leave their seat until the film is over. Additionally, it takes you one minute to escort a customer to their seat. An E-set is a contiguous section of seats such that there are exactly E empty seats next to one another, and there are no empty seats immediately to the left or right of this section For instance, this row of length 8 consists of one 1-set and one 6-set Seat 1 Customer Seat 3 Seat 4 Seat 5 Seat 6 Seat 7 Seat 8 (Empty) (Empty) (Empty) (Empty) (Empty) (Empty) (Empty) This is because there is 1 empty seat to the left of the only customer and 6 empty seats to the right. Even though there are smaller groups of 5, 4, 3, 2, and 1 empty seats to the right of this customer, each of those groups is directly next to an empty seat, so we only look at the largest grouping Your Task Given a line of S customers, write a function that returns the earliest time that a certain E-set occurs (or -1 if it never occurs) int solution (const std::vector& customers, const int E); The inputs to this function will be a vector of size S and a positive integer E. The entries of the vector represent what seat the customers are assigned to. For example, the vector f3, 4, 1, 2 > means the first customer in line has a ticket for seat 3, the second customer has seat 4, and so on. You can assume that both E and S are greater than or equal to 1. You can also assume that the customers vector is some permutation of the numbers 1 through S

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!