132k views
3 votes
There are N clients who have ordered N handmade items. The K-th client ordered exactly one item that takes T[K] hours to make. There is only one employee who makes items fo clients, and they work in the following manner: a spend one hour making the first item; b if the item is finished, the employee delivers it to the client immediately; c if the item is not finished, they put it after the N-th item for further work; d the employee starts making the next item. For example for T = [3, 1, 2] the employee spends 6 hours making items in the following order: [1, 2, 3, 1, 3, 1]. The first client waited 6 hours for their item, the second client received their item after 2 hours and the third client after 5 hours. What is the total time that clients need to wait for all ordered items? For the above example,

User Gevaraweb
by
7.3k points

1 Answer

4 votes

The total waiting time for all ordered items is the sum of the waiting times for individual clients: 6 hours + 2 hours + 5 hours = 13 hours.

How to solve

For the given sequence T = [3, 1, 2], representing the time taken for each item ordered by N clients, the total waiting time for all clients can be calculated.

The employee follows a process where each item is made in the order specified. For this sequence, the total time clients wait for their items is 6 hours for the first client, 2 hours for the second client, and 5 hours for the third client.

Therefore, the total waiting time for all ordered items is the sum of the waiting times for individual clients: 6 hours + 2 hours + 5 hours = 13 hours. Clients collectively wait for 13 hours for the completion and delivery of all the ordered handmade items.

User ImGreg
by
7.2k points