Patients stuck in hospital beds despite being medically fit to leave are costing an NHS trust about £21.5m a year.