Maximum principle, dynamic programming, and their connection in deterministic control