Sequential target detection and tracking via dynamic programming