This is close to utilitarian ethics. The problem is that, taken to the extreme, it is easy to yield obviously wrong moral decisions.
For example, if we define 'survive as long as possible' as having 1+ humans alive, we might decide we should kill 1/2 of the population (Thanos did nothing wrong).