The initial oxidation process of refractory alloy ceramics is closely related to their intrinsic properties such as surface adsorption or diffusion of oxygen atoms. We devise a machine learning model that predicts the full spectrum of adsorption energies for an oxygen atom on HfC1−xNx ceramic surfaces with quantum accuracy. With this approach, we show that the chemical complexity of carbonitride makes HfC1−xNx ceramics exhibit multiple types of adsorption sites with competing oxygen adsorption energies, leading to fewer preferable adsorption sites. In particular, we find that heavily doped N can change the stable adsorption site from the 3-fold hollow between metals and C atoms (MMC) to the top of Hf atoms (top-Hf), and the total number of preferable adsorption sites is regulated by their competing energies. In this scenario, we predict HfC0.76N0.24 has superior anti-oxidation performance, consistent with existing experimental measurements. Our findings can stimulate new strategies to enhance the oxidation resistance of refractory alloy ceramics.