Implement an algorithm to track the trajectory of multiple objects over time, then optimize it to run within a strict memory limit.