When the blocks collide, the compression of the spring is maximized at the instant both blocks have the same velocity. Find the maximum compression.

The system comprised of the two blocks have no external forces, so the velocity of the center of mass is constant. When the two blocks are moving with the same speed, their speeds from the center of mass's point of view is zero, so the speed at that instant of both blocks must equal the velocity of the center of mass. But,from here, i couldn't find a way to solve this without using conservation of energy. The furthest I got was that the impulse delivered to either block was equal to the integral of 1120 N/m *(x compressed) dt and I don't know how to integrate this.

My question is, is there a way to do it without energy?