  We analytically obtain the precision bounds of frequency measurements in
correlated Markovian and non-Markovian environments by using a variational
approach. It is verified that in standard Ramsey spectroscopy setup, the
metrological equivalence of product and maximally entangled states persists in
maximally correlated Markovian and non-Markovian environments. We find that the
optimal measurement can achieve a much higher resolution than standard Ramsey
spectroscopy in the correlated environments. When the number of particles in
the maximally entangled states is even, the precision bound decreases with
interrogation time; and when the number is odd, the precision bound is
independent of interrogation time, both in correlated Markovian and general
non-Markovian environments. In addition, the opposite case can appear in some
special non-Markovian environments.
