Work, for a constant force, is Force times distance.
Work done by force f(x) while moving something a distance a is given by
Here the work is the weight of the load, here 500g Newtons, plus the weight of the still to be pulled up. If you have already lefted the elevator 'x' m, there is 20- x m of cable still to be lifted so the weight still to be lifted is (20- x)(2g) Newtons. The work done is .
(There is an easy way to do this: the average value of linear function over an interval is the average of the largest and smallest values. Here the largest weight of the cable is when it is fully extended, 20(2g)= 40g Newtons, and its smallest value, at the top, is 0. The average weight of the cable is 20g Newtons so the average force applied is 20g+ 500g= 520g Newtons. The work done applying 520g Newtons for 20 m is 10400 Joules. Use that as a check on your integration.)