-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank.py
40 lines (33 loc) · 1.13 KB
/
bank.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
#bank.py
rounds, minutes = [int(i) for i in input("").split() ]
listI=[]
for r in range (0, rounds):
mon, min = [int (i) for i in input("").split()]
listI.append((mon,min))
listI.sort(key=lambda tup: (tup[0]), reverse = True)
amt = listI[0][0]
gndTotal = 0
maxWait= minutes
counterWait = 0
#print(listI)
for x in range (0, len(listI)):
currWait = listI[x][1]
currAmt = listI[x][0]
if (counterWait < maxWait):
if currWait== counterWait and currAmt>= amt:
amt = currAmt
if x==len(listI)-1 and listI[x-1][1]!=currWait:
gndTotal = gndTotal + currAmt
elif x==len(listI)-1 and listI[x-1][1]==currWait :
if currAmt > amt:
gndTotal = gndTotal + currAmt
else:
gndTotal = gndTotal + amt
elif currWait > counterWait :
counterWait = counterWait +1
# print("counterwait {}".format(counterWait))
# print("amt {}".format(amt))
gndTotal = gndTotal + amt
amt = currAmt
# print("gndTotal as of now {}".format(gndTotal))
print(gndTotal)