The hybrid trains use hydrogen fuel cells and lithium-iron phosphate batteries as energy sources. The powertrain has the advantage of zero emissions and high energy efficiency due to optimizing the power distribution strategy and the recovery of braking energy. This paper proposes an energy management strategy based on the Dynamic Programming Algorithm (DPA) to optimize the power allocation of both power sources to guarantee the power performance of the train and achieve optimal operation at the cost. The method is based on a dynamic programming algorithm to determine the optimum output power of a hydrogen-fuelled engine. Based on the operating characteristics of the train and the characteristics of the respective power sources, the objective function and constraints are established, and the principles for selecting the parameters of the optimization algorithm are presented. Finally, as a driving condition, the train is operated on a specific line in a minimum time operation. The vehicle model and control strategy designed in Matlab/Simulink environment is jointly simulated and verified. Simulation results show that the proposed optimization strategy results in significant savings in hydrogen consumption for the hybrid train compared to the SOC equalization strategy and better meets the train power performance requirements.