We examine the effects of the low-level substitution of S atoms by C and Si atoms on the superconductivity of H$_3$S with the $Imbar{3}m$ structure at megabar pressure. The hole doping can fine-tune the Fermi energy to reach the electronic density-of-states peak maximizing the electron-phonon coupling. This can boost the critical temperature from the original 203 K to 289 K and 283 K, respectively, for H$_3$S$_{0.962}$C$_{0.038}$ at 260 GPa and H$_3$S$_{0.960}$Si$_{0.040}$ at 230 GPa. The former may provide an explanation for the recent experimental observation of room-temperature superconductivity in a highly compressed C-S-H system [Nature 586, 373-377 (2020)]. Our work opens a new avenue for substantially raising the critical temperatures of hydrogen-rich materials.