프로그래밍/HackerRank
[HackerRank][Python3] Minimum Time Required
snoopybox
2018. 7. 17. 01:54
Problem :
https://www.hackerrank.com/challenges/minimum-time-required/problem
My Solution :
#!/usr/bin/env python3 def calc_prod(machines, days): prod = 0 for m in machines: prod += days // m return prod def calc_max_days(machines, goal): m = max(machines) c = machines.count(m) max_days = (goal*m) // c return max_days + 1 def minTime(machines, goal): low, high = 0, calc_max_days(machines, goal) while low < high: mid = (low + high) // 2 prod = calc_prod(machines, mid) if prod < goal: low = mid + 1 else: high = mid return high n, goal = map(int, input().split()) machines = list(map(int, input().rstrip().split())) ans = minTime(machines, goal) print(ans)