A Dynamic Approach to Optimizing Interventions and Mitigating Contagion Impacts in Financial Networks