Hey! I was doing this question and found it nice and tried to search for its editorials but couldn’t find one. It took almost a day to do this question even after reading codes. So here I have made editorial on it.
https://letsdocp.wordpress.com/2018/07/25/codechef-problem-krillin-is-dead-again/