Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T1 = 3
- T2 = 150
- def solution(S):
- lines = S.split('\n')
- bill = {}
- max_cost = 0
- phone_with_max_cost = ''
- for line in lines:
- info = line.split(',')
- time = info[0]
- time_as_arr = time.split(':')
- hours = int(time_as_arr[0])
- minutes = int(time_as_arr[1])
- seconds = int(time_as_arr[2])
- if hours == 0 and minutes < 5:
- cost = (minutes*60+seconds)*T1
- else:
- minutes += hours*60
- cost = minutes*T2+int(seconds>0)*T2
- phone = info[1]
- if phone not in bill:
- bill[phone] = cost
- else:
- bill[phone] += cost
- if bill[phone] > max_cost:
- max_cost = bill[phone]
- phone_with_max_cost = phone
- bill[phone_with_max_cost] = 0
- total = 0
- for item in bill:
- total += bill[item]
- return total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement