  We explore the origin of the trend of heavy elements in observed massive
exoplanets. Coupling of better measurements of mass ($M_p$) and radius of
exoplanets with planet structure models enables estimating the total heavy
element mass ($M_Z$) in these planets. The corresponding relation is
characterized by a power-law profile, $M_Z \propto M_p^{3/5}$. We develop a
simplified, but physically motivated analysis to investigate how the power-law
profile can be produced under the current picture of planet formation. Making
use of the existing semi-analytical formulae of accretion rates of pebbles and
planetesimals, our analysis shows that the relation can be reproduced well if
it traces the final stage of planet formation. In the stage, planets accrete
solids from gapped planetesimal disks and gas accretion is limited by disk
evolution. We also find that dust accretion accompanying with gas accretion
does not contribute to $M_Z$ for planets with $M_p < 10^3 M_{\oplus}$. Our
findings are broadly consistent with that of previous studies, yet we
explicitly demonstrate how planetesimal dynamics is crucial for better
understanding the relation. While our approach is simple, we can also reproduce
the trend of a correlation between planet metallicity and $M_p$ that is
obtained by detailed population synthesis calculations, when the same
assumption is adopted. Our analysis suggests that pebble accretion would not
play a direct role at the final stage of planet formation, whereas radial drift
of pebbles might be important indirectly for metal enrichment of planets.
Detailed numerical simulations and more observational data are required for
confirming our analysis.
