[HackerRank][Python3] Minimum Time Required
2018. 7. 17. 01:54 |
프로그래밍/HackerRank
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)
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] Queues: A Tale of Two Stacks (0) | 2018.07.19 |
|---|---|
| [HackerRank][Python3] Abbreviation (0) | 2018.07.18 |
| [HackerRank][Python3] Max Array Sum (0) | 2018.07.18 |
| [HackerRank][Python3] Making Candies (0) | 2018.07.18 |
| [HackerRank][Python3] Pairs (0) | 2018.07.17 |
| [HackerRank][Python3] Hash Tables: Ice Cream Parlor (0) | 2018.07.16 |
| [HackerRank][Python3] Triple sum (0) | 2018.07.16 |
| [HackerRank][Python3] Max Min (0) | 2018.07.16 |
최근에 달린 댓글 최근에 달린 댓글