NHS to fund extra beds and ambulances to tackle long emergency care waits