Finite-Horizon OptimalControl of Discrete-Time Switched Linear Systems