WC 2.3 Bus Stop Queue

Its Vacation Time and most of the people prefer travelling by bus. There are n groups of people at bus stop. The ith group has A[i] people. The frequency of bus is 30 minutes and each bus can carry at most S people

Note: The order of groups do not change. If some group cannot fit all its members in the bus it waits for the next bus along with other groups standing behind them. You need to determine how many buses are needed to transport n groups of people in a batch.

Note: While submitting the code print the output as all sum of outputs for all the batches of people.


Example:
For a batch {2 3 2 1} with bus size 3, the output should be 3. This is as 2 people enter Bus 1, 3 people enter Bus 2, and remaining groups of 2 and 1 can enter Bus3.
For a batch {1 2 1} with bus size 4, the output should be 1, since all groups can fit in the first bus.

Input cases:
1. S= 5, A= {4}

2. S= 1, A= {1 1 1 1 1}

3. S= 4, A= {1 3 2 3 4 1}

4. S= 8, A= {6 1 1 1 4 5}

5. S= 10, A= {1 10 1 10 1 1 7 8 6 7}

6. S= 1, A= {1 1 1 1 1 1 1 1 1 1}

7. S= 2, A= {2 2 1 1 1 1 1 2 1 2}

8. S= 100, A= { 14 67 15 28 21}

9. S= 100, A= { 14 67 19 2 99 1 99}


Click to view hint

This challenge is worth 80 points.

You must be logged in to submit a solution

View ranklist for this challenge
About scoring and submission

Contact Us


Krish Shah : 9323115454

Kaustubh Khavnekar : 9769408039



Privacy Policy