We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Minimum Time Required
- Discussions
Minimum Time Required
Minimum Time Required
Sort by
recency
|
155 Discussions
|
Please Login in order to post a comment
Decent, but one error and one optimization. The error: in the while, the conditionals should be if count >= goal: worst = mid - 1 result = mid else: best = mid + 1 `
The optimization: the mid calculation should be
mid = (worst + best) // 2
ez
let M be the min element of machines, then M*goal is 10^18 at most = 2^64 at most
O(n * log(M * goal)), the log cannot exceed 64
why is this TLE? I am using binary search and the last for loop -- couldn't possibly go too much back.
The binary search is certainly a great idea, but solutions I see all start from 0 or 1. The minum days is fastest-machine/number-of-machines * item_targets and the maxium days is slowest-machine/number-of-machines * item_targets:
JS binary search