The rope hangs.

x is any point on the rope.

q mass density of the rope to unit length.

On the top of the building x=0, whole lenght of the rope is L.

So 0 <= x <=L.

The work done to lift dx of the rope at position x is

dW = dm g x

where

dm = q dx.

So

dW = g q x dx.

The work done to lift all the rope is

The work done to lift upper half is

The work done to lift buttom half is

It is clear that