A polynomial-time algorithm for a class of linear complementarity problems