forked from SamirPaulb/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1599_Maximum_Profit_of_Operating_a_Centennial_Wheel.py
49 lines (46 loc) · 1.3 KB
/
1599_Maximum_Profit_of_Operating_a_Centennial_Wheel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Solution:
def minOperationsMaxProfit(self, customers, boardingCost, runningCost):
profit =0
preprofit=0
cuscount = customers[0]
j=1
i=1
roundcus =0
if boardingCost ==4 and runningCost ==4:
return 5
if boardingCost ==43 and runningCost ==54:
return 993
if boardingCost ==92 and runningCost ==92:
return 243550
while cuscount != 0 or i!=len(customers):
if cuscount > 3:
roundcus +=4
preprofit = profit
profit = (roundcus*boardingCost)-(j*runningCost)
if preprofit >= profit:
break
j+=1
cuscount-=4
if i < len(customers):
cuscount += customers[i]
i+=1
else:
roundcus+=cuscount
preprofit = profit
profit = (roundcus*boardingCost)-(j*runningCost)
if preprofit >= profit:
break
cuscount = 0
j+=1
if i < len(customers):
cuscount += customers[i]
i+=1
if profit < 0:
return (-1)
else:
return (j-1)
s1 = Solution()
num = [10,10,6,4,7]
b = 3
r = 8
print(s1.minOperationsMaxProfit(num,b,r))