It has been a challenge to understand the experimental data on both the nuclear modification factor and elliptic flow of D0 mesons in p−Pb collisions at LHC energies. In this work, we study these collisions with an improved multi-phase transport model. By including the independent fragmentation and a significant Cronin effect (i.e., transverse momentum broadening) for charm quarks, we provide the first simultaneous description of the D0 meson RpA and v2 data at pT≤8 GeV/c. The model also reasonably describes the D0 meson pT spectra and the low-pT charged hadron spectra, RpA and v2. Our results show that both parton interactions and the Cronin effect are important for the D0 meson RpA, while parton interactions are mostly responsible for the D0 meson v2. It is thus essential to include the Cronin effect for the simultaneous description of the D0 meson RpA and v2. This work implies that the Cronin effect could also be important for heavy hadrons in large systems.