Avoiding Undesired Future with Minimal Cost in Non-Stationary Environments