As far as I know, they do have the same basic sensor technology (not the same sensor), but the key difference between the two cameras in this area is the bit depth. The K-01 has a bit depth of 12 and the K-5 has 14, which means that the K-01 can have 2^12 (4096) different levels of red, green, and blue. The K-5 can have 2^14 (16384) different levels. So, being able to discern more variance in the colors can give the K-5 an advantage in dynamic range.
It should be noted that bit depth doesn't always mean increased dynamic range. If the two ends of the range are the same between the cameras, then the extra 2 bits don't mean anything to dynamic range, they just effect things like posterization. If the ends are different, it's very likely the ends can move farther apart as a result of increased information available (each additional bit doubles the information).