Ground-state density-matrix algorithm for excited-state adiabatic surfaces: application to polyenes