Imagine you're managing a computer system with two memory sticks that are being consumed by a faulty program. This program has a peculiar behavior: it consumes an increasing amount of memory each second!
You start with two memory sticks containing memory1 and memory2 bits respectively. At the i-th second (starting from second 1), the program tries to allocate exactly i bits of memory. The allocation always goes to the memory stick with more available memory, or to the first stick if both have equal memory.
The program will crash when neither memory stick has enough bits to satisfy the current allocation request. Your task is to determine exactly when this crash occurs and how much memory remains in each stick.
Goal: Return [crashTime, memory1crash, memory2crash] where crashTime is when the program crashed, and the other values are the remaining memory in each stick.
Input & Output
Constraints
- 0 โค memory1, memory2 โค 231 - 1
- The program always starts from second 1
- Memory allocation always goes to the stick with more memory, or to memory1 if equal