A said that when I came back, C hadn't come back.
B said that Ding had fallen asleep when I came back, and so did I.
C said that B was sleeping when I came in.
Ding said I went to sleep when I came back, and I didn't pay attention to anything else.
What they said is true. Do you know who came back last?
It is C.
A means that a is earlier than C.
B means d is earlier than B.
C means that b is earlier than C.
Because what they said is true.
So a, b and d are all earlier than C.
C will be back at the latest.