Your question is Virus Memory Consumption Timing. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A monitoring simulation for KeyValue infrastructure models a virus that consumes t bits during the first second, t + 1 bits during the second, and one additional bit more each subsequent second. Given the available RAM and the initial consumption t, return the maximum number of complete seconds the virus can run.
The virus may consume memory only when the full amount required for that second is available. Do not simulate one second at a time, and do not use floating-point arithmetic.
Implement max_survival_time(memory, t).
memory is a non-negative integer representing available RAM bits.t is a positive integer representing first-second consumption.k, where k is the largest value satisfying:
t + (t + 1) + ... + (t + k - 1) <= memory.def max_survival_time(memory, t):