# Arup Guha
# 11/9/2020
# Solution to COP 2930 Program 9 Part B

def timeToWait(voteTimes,numBooths):

    res = 0

    # Go to each booth.
    for i in range(0,numBooths):

        # Accumulator for this booth.
        thistime = 0
        
        # First person is person i and we skip numBooths people each time.
        for j in range(i, len(voteTimes), numBooths):
            thistime += voteTimes[j]

        # Could use max function here, but I am doing it fron scratch.
        if thistime > res:
            res = thistime

    return res

# Store some tests here.
def tests():

    # Try first case with each # of booths.
    for booths in range(1, 15):
        print("Booths = ", booths,"time = ",timeToWait([3, 8, 2, 9, 6, 5, 12, 3, 4, 4, 8, 9, 7], booths))

    # Three other test cases, answers are 90, 19, 5.
    print(timeToWait([3,90,5],2))
    print(timeToWait([1,2,3,4,5,6,19,17,16,15,14,13,12],7))
    print(timeToWait([5], 100))

    # Last three cases, 125, 25, 11
    print(timeToWait([3,6,2,50,6,9,11,4,7,100,2,1,90,3,2,15,8,7,95,1,2], 4))
    print(timeToWait([17,16,14,13,12,11,10,9,8], 5))
    print(timeToWait([1,2,3,2,1,2,3,2,1,2,3,2,1,2,3,2,1,2,3,2,1,2,3,2,1,2,3,2,1,2,3,2,1], 7))
    
# Run the tests.
tests()
