Maximum Profit of Operating a Centennial Wheel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Solution:
    def minOperationsMaxProfit(self, customers: List[int], boardingCost: int, runningCost: int) -> int:
        wait = 0
        prof = 0
        max_prof = 0
        max_i = -1
        i = 0
        while i < len(customers) or wait > 0:
            if i < len(customers):
                wait += customers[i]
            boarding = min(4, wait)
            prof += boarding * boardingCost - runningCost
            wait -= boarding
            if max_prof < prof:
                max_prof = prof
                max_i = i + 1
            i += 1
        return max_i