Description

Bit Party

Design a hardware module that optimizes robot bit production. Given R robots and B bits needed, each robot has a processing time and capacity. Use binary search to find the minimum time needed, where robots can work in parallel and some may finish earlier.

Example: 2 robots, need 8 bits. Robot 1: 5 time/bit, capacity 2, setup 1. Robot 2: 8 time/bit, capacity 4, setup 3. Find minimum time.

Source: Google Code Jam 2018 Round 1A - Problem C: Bit Party

Input

r

32-bit Unsigned Integer
Number of robots available.

b

32-bit Unsigned Integer
Total minutes available.

c

Stream of (32-bit Unsigned Integer, 32-bit Unsigned Integer, 32-bit Unsigned Integer)
Robot configurations (max_bits, time_per_bit, setup_time).

Output

64-bit Unsigned Integer
Maximum bits that can be processed.