Achieving linear-scaling computational cost for the polarizable continuum model of solvation