Description
Standing Ovation
Design a hardware module that simulates an auditorium where audience members give a standing ovation. Each person i will stand only if at least i people have already stood up. Given the initial shyness levels, calculate the minimum number of additional people needed to guarantee everyone eventually stands.
Example: For audience with counts [1,1,1,1,1] and smax=4, calculate the minimum number of additional people needed.
Source: Google Code Jam 2015 Qualification Round - Problem A: Standing Ovation
Input
smax
8-bit Unsigned IntegerMaximum shyness level (0-9)
counts
Stream of 8-bit Unsigned IntegerPeople count per shyness level
Output
8-bit Unsigned Integer
Minimum additional people needed